1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-01-31 20:50:08 +01:00

55 lines
961 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
pub trait Resource<T: ResourcePath> {
fn resource_path(&mut self) -> &mut Path<T>;
}
pub trait ResourcePath {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str;
}
impl ResourcePath for String {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str {
self.as_str()
}
}
impl<'a> ResourcePath for &'a str {
2019-01-05 13:19:25 -08:00
fn path(&self) -> &str {
self
}
}
2019-12-07 09:59:39 +06:00
impl ResourcePath for bytesrting::ByteString {
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::{Quoter, Url};
2019-02-01 13:25:56 -08:00
2019-01-05 22:00:38 -08:00
#[cfg(feature = "http")]
mod http_support {
use super::ResourcePath;
2019-01-05 22:00:38 -08:00
use http::Uri;
impl ResourcePath for Uri {
2019-01-05 22:00:38 -08:00
fn path(&self) -> &str {
self.path()
}
}
}