diff options
Diffstat (limited to 'src/request.rs')
-rw-r--r-- | src/request.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/request.rs b/src/request.rs index 195e601..d89248c 100644 --- a/src/request.rs +++ b/src/request.rs @@ -13,6 +13,7 @@ use crate::response::{SputnikHeaders, delete_cookie}; const CSRF_COOKIE_NAME : &str = "csrf"; +/// Adds convenience methods to [`http::request::Parts`](Parts). pub trait SputnikParts { /// Parses the query string of the request into a given struct. fn query<X: DeserializeOwned>(&self) -> Result<X,QueryError>; @@ -32,7 +33,7 @@ pub trait SputnikParts { fn response_headers(&mut self) -> &mut HeaderMap; } -impl SputnikParts for hyper::http::request::Parts { +impl SputnikParts for Parts { fn query<T: DeserializeOwned>(&self) -> Result<T,QueryError> { serde_urlencoded::from_str::<T>(self.uri.query().unwrap_or("")).map_err(QueryError) } @@ -185,6 +186,7 @@ impl CsrfToken { } } +/// Adds deserialization methods to [`hyper::Body`]. #[async_trait] pub trait SputnikBody { async fn into_bytes(self) -> Result<Bytes, BodyError>; |