diff --git a/Cargo.lock b/Cargo.lock index dad89f4..939c97f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1274,7 +1274,7 @@ dependencies = [ [[package]] name = "servable" -version = "0.0.5" +version = "0.0.7" dependencies = [ "axum", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 3ed32e7..7602f3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] rust-version = "1.90.0" edition = "2024" -version = "0.0.5" +version = "0.0.7" license = "GPL-3.0" repository = "https://github.com/rm-dr/servable" readme = "README.md" diff --git a/crates/servable/src/servable/mod.rs b/crates/servable/src/servable/mod.rs index 401bb15..cc89369 100644 --- a/crates/servable/src/servable/mod.rs +++ b/crates/servable/src/servable/mod.rs @@ -60,6 +60,12 @@ impl ServableWithRoute { pub fn route(&self) -> &str { &self.route } + + /// Get the route associated with this resource, + /// with the given prefix + pub fn route_at(&self, prefix: &str) -> String { + format!("{prefix}/{}", &*self.route) + } } impl Servable for ServableWithRoute { @@ -82,7 +88,7 @@ impl Servable for ServableWithRoute { } } -impl Servable for &'static S { +impl Servable for &S { #[inline(always)] fn head<'a>( &'a self, diff --git a/crates/servable/src/types.rs b/crates/servable/src/types.rs index 7a487a4..056eafe 100644 --- a/crates/servable/src/types.rs +++ b/crates/servable/src/types.rs @@ -91,8 +91,7 @@ pub struct RenderContext { } /// The type of device that requested a page -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[derive(Default)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] pub enum DeviceType { /// This is a mobile device, like a phone. Mobile, @@ -100,10 +99,9 @@ pub enum DeviceType { /// This is a device with a large screen /// and a mouse, like a laptop. #[default] - Desktop, + Desktop, } - /// Inferred information about the client /// that requested a certain route. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]