diff --git a/src/path.rs b/src/path.rs index bcd4439fe..9fe94f256 100644 --- a/src/path.rs +++ b/src/path.rs @@ -1,6 +1,9 @@ use std::ops::Index; use std::rc::Rc; +use serde::de; + +use crate::de::PathDeserializer; use crate::RequestPath; #[derive(Debug, Clone, Copy)] @@ -149,6 +152,11 @@ impl Path { params: self, } } + + /// Try to deserialize matching parameters to a specified type `U` + pub fn load<'de, U: serde::Deserialize<'de>>(&'de self) -> Result { + de::Deserialize::deserialize(PathDeserializer::new(self)) + } } #[derive(Debug)]