aboutsummaryrefslogtreecommitdiff
path: root/src/request.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-01-29 11:38:33 +0100
committerMartin Fischer <martin@push-f.com>2021-01-29 11:38:57 +0100
commit10b5cd07f07cefd15450001375cd1c3e6927cc8a (patch)
tree8bd05662b4eacb54f6537c18788a33f861714fc3 /src/request.rs
parent6c44846f6bf5901eaa12b943646632bd2163c898 (diff)
add documentation
Diffstat (limited to 'src/request.rs')
-rw-r--r--src/request.rs4
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>;