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

51 lines
848 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-03-03 21:00:58 -08:00
pub trait Resource {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str;
}
2019-03-03 21:00:58 -08:00
impl Resource for String {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str {
self.as_str()
}
}
2019-03-03 21:00:58 -08:00
impl<'a> Resource for &'a str {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str {
self
}
}
2019-03-03 21:00:58 -08:00
impl<T: AsRef<[u8]>> Resource 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-03-03 21:00:58 -08:00
use super::Resource;
2019-01-05 22:00:38 -08:00
use http::Uri;
2019-03-03 21:00:58 -08:00
impl Resource for Uri {
2019-01-05 22:00:38 -08:00
fn path(&self) -> &str {
self.path()
}
}
}