actix_router/
resource_path.rs

1use crate::Path;
2
3// TODO: this trait is necessary, document it
4// see impl Resource for ServiceRequest
5pub trait Resource {
6    /// Type of resource's path returned in `resource_path`.
7    type Path: ResourcePath;
8
9    fn resource_path(&mut self) -> &mut Path<Self::Path>;
10}
11
12pub trait ResourcePath {
13    fn path(&self) -> &str;
14}
15
16impl ResourcePath for String {
17    fn path(&self) -> &str {
18        self.as_str()
19    }
20}
21
22impl<'a> ResourcePath for &'a str {
23    fn path(&self) -> &str {
24        self
25    }
26}
27
28impl ResourcePath for bytestring::ByteString {
29    fn path(&self) -> &str {
30        self
31    }
32}
33
34#[cfg(feature = "http")]
35impl ResourcePath for http::Uri {
36    fn path(&self) -> &str {
37        self.path()
38    }
39}