aboutsummaryrefslogtreecommitdiff
path: root/src/hyper_body.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-12-23 07:51:48 +0100
committerMartin Fischer <martin@push-f.com>2021-12-23 23:05:10 +0100
commit460150079f7bbf868c42d0c3c10119a15e9d6b84 (patch)
treea7bea00b74670dad4ee663da7cbbb2a77d658496 /src/hyper_body.rs
parent62fa053b4be22cdedfb4ffeb3045e9fc2d854292 (diff)
format with cargo fmt
Diffstat (limited to 'src/hyper_body.rs')
-rw-r--r--src/hyper_body.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/hyper_body.rs b/src/hyper_body.rs
index 50efdc3..7400633 100644
--- a/src/hyper_body.rs
+++ b/src/hyper_body.rs
@@ -15,17 +15,22 @@ impl EmptyBuilder<hyper::Body> for Builder {
/// Adds deserialization methods to `hyper::Body`.
pub trait SputnikBody {
/// Parses a `application/x-www-form-urlencoded` request body into a given struct.
- fn into_form<T: DeserializeOwned>(self) -> Pin<Box<dyn Future<Output=Result<T, FormError>> + Send + Sync>>;
+ fn into_form<T: DeserializeOwned>(
+ self,
+ ) -> Pin<Box<dyn Future<Output = Result<T, FormError>> + Send + Sync>>;
/// Attempts to deserialize the request body as JSON.
#[cfg(feature = "hyper_body_json")]
#[cfg_attr(docsrs, doc(cfg(feature = "hyper_body_json")))]
- fn into_json<T: DeserializeOwned>(self) -> Pin<Box<dyn Future<Output=Result<T, JsonError>> + Send + Sync>>;
+ fn into_json<T: DeserializeOwned>(
+ self,
+ ) -> Pin<Box<dyn Future<Output = Result<T, JsonError>> + Send + Sync>>;
}
impl SputnikBody for hyper::Body {
-
- fn into_form<T: DeserializeOwned>(self) -> Pin<Box<dyn Future<Output=Result<T, FormError>> + Send + Sync>> {
+ fn into_form<T: DeserializeOwned>(
+ self,
+ ) -> Pin<Box<dyn Future<Output = Result<T, FormError>> + Send + Sync>> {
Box::pin(async move {
let full_body = hyper::body::to_bytes(self).await.map_err(BodyError)?;
Ok(serde_urlencoded::from_bytes::<T>(&full_body)?)
@@ -34,7 +39,9 @@ impl SputnikBody for hyper::Body {
#[cfg(feature = "hyper_body_json")]
#[cfg_attr(docsrs, doc(cfg(feature = "hyper_body_json")))]
- fn into_json<T: DeserializeOwned>(self) -> Pin<Box<dyn Future<Output=Result<T, JsonError>> + Send + Sync>> {
+ fn into_json<T: DeserializeOwned>(
+ self,
+ ) -> Pin<Box<dyn Future<Output = Result<T, JsonError>> + Send + Sync>> {
Box::pin(async move {
let full_body = hyper::body::to_bytes(self).await.map_err(BodyError)?;
Ok(serde_json::from_slice::<T>(&full_body)?)
@@ -64,4 +71,4 @@ pub enum JsonError {
#[error("json deserialize error: {0}")]
Deserialize(#[from] serde_json::Error),
-} \ No newline at end of file
+}