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-04 11:47:03 -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;
|
|
|
|
}
|
|
|
|
|
2019-03-04 11:47:03 -08:00
|
|
|
impl ResourcePath for String {
|
2019-01-05 13:19:25 -08:00
|
|
|
fn path(&self) -> &str {
|
|
|
|
self.as_str()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 11:47:03 -08:00
|
|
|
impl<'a> ResourcePath for &'a str {
|
2019-01-05 13:19:25 -08:00
|
|
|
fn path(&self) -> &str {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 11:47:03 -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")]
|
2019-04-07 22:48:18 -07:00
|
|
|
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 {
|
2019-03-04 11:47:03 -08:00
|
|
|
use super::ResourcePath;
|
2019-01-05 22:00:38 -08:00
|
|
|
use http::Uri;
|
|
|
|
|
2019-03-04 11:47:03 -08:00
|
|
|
impl ResourcePath for Uri {
|
2019-01-05 22:00:38 -08:00
|
|
|
fn path(&self) -> &str {
|
|
|
|
self.path()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|