1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-02-07 22:34:23 +01:00

51 lines
872 B
Rust
Raw Normal View History

2019-01-05 13:19:25 -08:00
//! Resource path matching library.
mod de;
mod path;
2019-02-09 07:24:35 -08:00
mod resource;
2019-01-05 13:19:25 -08:00
mod router;
pub use self::de::PathDeserializer;
pub use self::path::Path;
2019-02-09 07:24:35 -08:00
pub use self::resource::ResourceDef;
2019-01-05 22:00:38 -08:00
pub use self::router::{ResourceInfo, Router, RouterBuilder};
2019-01-05 13:19:25 -08:00
2019-02-09 07:24:35 -08:00
pub trait ResourcePath {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str;
}
2019-02-09 07:24:35 -08:00
impl ResourcePath for String {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str {
self.as_str()
}
}
2019-02-09 07:24:35 -08:00
impl<'a> ResourcePath for &'a str {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str {
self
}
}
2019-02-09 07:24:35 -08:00
impl<T: AsRef<[u8]>> ResourcePath for string::String<T> {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str {
&*self
}
}
2019-01-05 22:00:38 -08:00
2019-02-01 13:25:56 -08:00
#[cfg(feature = "http")]
mod url;
#[cfg(feature = "http")]
pub use self::url::Url;
2019-01-05 22:00:38 -08:00
#[cfg(feature = "http")]
mod http_support {
2019-02-09 07:24:35 -08:00
use super::ResourcePath;
2019-01-05 22:00:38 -08:00
use http::Uri;
2019-02-09 07:24:35 -08:00
impl ResourcePath for Uri {
2019-01-05 22:00:38 -08:00
fn path(&self) -> &str {
self.path()
}
}
}