From 2dbc5899f3f9da76c105778faad693d9b1f57231 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Wed, 3 Jan 2024 07:31:13 -0500 Subject: [PATCH] cargo fmt --- leptos_server/src/lib.rs | 4 +-- leptos_server/src/multi_action.rs | 2 +- server_fn/src/client.rs | 9 ++++-- server_fn/src/codec/cbor.rs | 27 ++++++++++++------ server_fn/src/codec/json.rs | 25 +++++++++++------ server_fn/src/codec/mod.rs | 19 +++++++++---- server_fn/src/codec/multipart.rs | 27 ++++++++++++------ server_fn/src/codec/stream.rs | 25 +++++++++++------ server_fn/src/codec/url.rs | 29 ++++++++++++------- server_fn/src/middleware/mod.rs | 46 ++++++++++++++++++++++--------- server_fn/src/redirect.rs | 3 +- server_fn/src/request/axum.rs | 13 +++++---- server_fn/src/request/browser.rs | 3 +- server_fn/src/request/mod.rs | 28 +++++++++++++------ server_fn/src/request/reqwest.rs | 10 +++---- server_fn/src/response/actix.rs | 18 +++++++++--- server_fn/src/response/browser.rs | 11 +++++--- server_fn/src/response/http.rs | 17 +++++++++--- server_fn/src/response/mod.rs | 33 ++++++++++++++++------ 19 files changed, 237 insertions(+), 112 deletions(-) diff --git a/leptos_server/src/lib.rs b/leptos_server/src/lib.rs index 8d925feda..6055e1393 100644 --- a/leptos_server/src/lib.rs +++ b/leptos_server/src/lib.rs @@ -113,9 +113,7 @@ ////! CBOR forms encounter the same issue as `PUT`, `DELETE`, or JSON: they do not degrade gracefully if the WASM version of ////! your app is not available. -pub use server_fn::{ - error::ServerFnErrorErr, ServerFnError, -}; +pub use server_fn::{error::ServerFnErrorErr, ServerFnError}; mod action; mod multi_action; diff --git a/leptos_server/src/multi_action.rs b/leptos_server/src/multi_action.rs index 18d480344..bd9a7fa72 100644 --- a/leptos_server/src/multi_action.rs +++ b/leptos_server/src/multi_action.rs @@ -1,8 +1,8 @@ -use server_fn::{ServerFn, ServerFnError}; use leptos_reactive::{ create_rw_signal, is_suppressing_resource_load, signal_prelude::*, spawn_local, store_value, untrack, ReadSignal, RwSignal, StoredValue, }; +use server_fn::{ServerFn, ServerFnError}; use std::{future::Future, pin::Pin, rc::Rc}; /// An action that synchronizes multiple imperative `async` calls to the reactive system, diff --git a/server_fn/src/client.rs b/server_fn/src/client.rs index d17113150..cd3599e63 100644 --- a/server_fn/src/client.rs +++ b/server_fn/src/client.rs @@ -14,7 +14,8 @@ pub trait Client { pub mod browser { use super::Client; use crate::{ - error::ServerFnError, request::browser::BrowserRequest, response::browser::BrowserResponse, + error::ServerFnError, request::browser::BrowserRequest, + response::browser::BrowserResponse, }; use send_wrapper::SendWrapper; use std::future::Future; @@ -27,7 +28,8 @@ pub mod browser { fn send( req: Self::Request, - ) -> impl Future>> + Send { + ) -> impl Future>> + + Send { SendWrapper::new(async move { req.0 .take() @@ -56,7 +58,8 @@ pub mod reqwest { fn send( req: Self::Request, - ) -> impl Future>> + Send { + ) -> impl Future>> + + Send { CLIENT .execute(req) .map_err(|e| ServerFnError::Request(e.to_string())) diff --git a/server_fn/src/codec/cbor.rs b/server_fn/src/codec/cbor.rs index e6ca6ea32..e9acb50f5 100644 --- a/server_fn/src/codec/cbor.rs +++ b/server_fn/src/codec/cbor.rs @@ -1,10 +1,11 @@ use super::{Encoding, FromReq, FromRes, IntoReq, IntoRes}; -use crate::error::ServerFnError; -use crate::request::{ClientReq, Req}; -use crate::response::{ClientRes, Res}; +use crate::{ + error::ServerFnError, + request::{ClientReq, Req}, + response::{ClientRes, Res}, +}; use bytes::Bytes; -use serde::de::DeserializeOwned; -use serde::Serialize; +use serde::{de::DeserializeOwned, Serialize}; /// Pass arguments and receive responses using `cbor` in a `POST` request. pub struct Cbor; @@ -18,11 +19,20 @@ where Request: ClientReq, T: Serialize + Send, { - fn into_req(self, path: &str, accepts: &str) -> Result> { + fn into_req( + self, + path: &str, + accepts: &str, + ) -> Result> { let mut buffer: Vec = Vec::new(); ciborium::ser::into_writer(&self, &mut buffer) .map_err(|e| ServerFnError::Serialization(e.to_string()))?; - Request::try_new_post_bytes(path, accepts, Cbor::CONTENT_TYPE, Bytes::from(buffer)) + Request::try_new_post_bytes( + path, + accepts, + Cbor::CONTENT_TYPE, + Bytes::from(buffer), + ) } } @@ -58,7 +68,8 @@ where { async fn from_res(res: Response) -> Result> { let data = res.try_into_bytes().await?; - ciborium::de::from_reader(data.as_ref()).map_err(|e| ServerFnError::Args(e.to_string())) + ciborium::de::from_reader(data.as_ref()) + .map_err(|e| ServerFnError::Args(e.to_string())) } } diff --git a/server_fn/src/codec/json.rs b/server_fn/src/codec/json.rs index fc944453e..f90f420a6 100644 --- a/server_fn/src/codec/json.rs +++ b/server_fn/src/codec/json.rs @@ -1,10 +1,11 @@ use super::{Encoding, FromReq, FromRes}; -use crate::error::ServerFnError; -use crate::request::{ClientReq, Req}; -use crate::response::{ClientRes, Res}; -use crate::{IntoReq, IntoRes}; -use serde::de::DeserializeOwned; -use serde::Serialize; +use crate::{ + error::ServerFnError, + request::{ClientReq, Req}, + response::{ClientRes, Res}, + IntoReq, IntoRes, +}; +use serde::{de::DeserializeOwned, Serialize}; /// Pass arguments and receive responses as JSON in the body of a `POST` request. pub struct Json; @@ -17,7 +18,11 @@ where Request: ClientReq, T: Serialize + Send, { - fn into_req(self, path: &str, accepts: &str) -> Result> { + fn into_req( + self, + path: &str, + accepts: &str, + ) -> Result> { let data = serde_json::to_string(&self) .map_err(|e| ServerFnError::Serialization(e.to_string()))?; Request::try_new_post(path, accepts, Json::CONTENT_TYPE, data) @@ -31,7 +36,8 @@ where { async fn from_req(req: Request) -> Result> { let string_data = req.try_into_string().await?; - serde_json::from_str::(&string_data).map_err(|e| ServerFnError::Args(e.to_string())) + serde_json::from_str::(&string_data) + .map_err(|e| ServerFnError::Args(e.to_string())) } } @@ -54,6 +60,7 @@ where { async fn from_res(res: Response) -> Result> { let data = res.try_into_string().await?; - serde_json::from_str(&data).map_err(|e| ServerFnError::Deserialization(e.to_string())) + serde_json::from_str(&data) + .map_err(|e| ServerFnError::Deserialization(e.to_string())) } } diff --git a/server_fn/src/codec/mod.rs b/server_fn/src/codec/mod.rs index 7883ec332..56ab0bf70 100644 --- a/server_fn/src/codec/mod.rs +++ b/server_fn/src/codec/mod.rs @@ -29,23 +29,32 @@ pub trait FromReq where Self: Sized, { - fn from_req(req: Request) -> impl Future>> + Send; + fn from_req( + req: Request, + ) -> impl Future>> + Send; } pub trait IntoReq { - fn into_req(self, path: &str, accepts: &str) -> Result>; + fn into_req( + self, + path: &str, + accepts: &str, + ) -> Result>; } pub trait FromRes where Self: Sized, { - fn from_res(res: Response) - -> impl Future>> + Send; + fn from_res( + res: Response, + ) -> impl Future>> + Send; } pub trait IntoRes { - fn into_res(self) -> impl Future>> + Send; + fn into_res( + self, + ) -> impl Future>> + Send; } pub trait Encoding { diff --git a/server_fn/src/codec/multipart.rs b/server_fn/src/codec/multipart.rs index 987902184..aa11fcd6f 100644 --- a/server_fn/src/codec/multipart.rs +++ b/server_fn/src/codec/multipart.rs @@ -1,8 +1,9 @@ use super::{Encoding, FromReq}; -use crate::error::ServerFnError; -use crate::request::browser::BrowserFormData; -use crate::request::{ClientReq, Req}; -use crate::IntoReq; +use crate::{ + error::ServerFnError, + request::{browser::BrowserFormData, ClientReq, Req}, + IntoReq, +}; use futures::StreamExt; use multer::Multipart; use web_sys::FormData; @@ -46,9 +47,17 @@ where Request: ClientReq, T: Into, { - fn into_req(self, path: &str, accepts: &str) -> Result> { + fn into_req( + self, + path: &str, + accepts: &str, + ) -> Result> { let multi = self.into(); - Request::try_new_multipart(path, accepts, multi.into_client_data().unwrap()) + Request::try_new_multipart( + path, + accepts, + multi.into_client_data().unwrap(), + ) } } @@ -64,8 +73,10 @@ where .and_then(|ct| multer::parse_boundary(ct).ok()) .expect("couldn't parse boundary"); let stream = req.try_into_stream()?; - let data = - multer::Multipart::new(stream.map(|data| data.map_err(|e| e.to_string())), boundary); + let data = multer::Multipart::new( + stream.map(|data| data.map_err(|e| e.to_string())), + boundary, + ); Ok(MultipartData::Server(data).into()) } } diff --git a/server_fn/src/codec/stream.rs b/server_fn/src/codec/stream.rs index 7999a8caf..8158261ac 100644 --- a/server_fn/src/codec/stream.rs +++ b/server_fn/src/codec/stream.rs @@ -1,11 +1,12 @@ -use std::pin::Pin; - use super::{Encoding, FromRes}; -use crate::error::{NoCustomError, ServerFnError}; -use crate::response::{ClientRes, Res}; -use crate::IntoRes; +use crate::{ + error::{NoCustomError, ServerFnError}, + response::{ClientRes, Res}, + IntoRes, +}; use bytes::Bytes; use futures::{Stream, StreamExt}; +use std::pin::Pin; pub struct Streaming; @@ -38,7 +39,9 @@ pub struct ByteStream( ); impl ByteStream { - pub fn into_inner(self) -> impl Stream>> + Send { + pub fn into_inner( + self, + ) -> impl Stream>> + Send { self.0 } } @@ -53,7 +56,8 @@ where } } -impl IntoRes for ByteStream +impl IntoRes + for ByteStream where Response: Res, CustErr: 'static, @@ -84,7 +88,9 @@ pub struct TextStream( ); impl TextStream { - pub fn into_inner(self) -> impl Stream>> + Send { + pub fn into_inner( + self, + ) -> impl Stream>> + Send { self.0 } } @@ -99,7 +105,8 @@ where } } -impl IntoRes for TextStream +impl IntoRes + for TextStream where Response: Res, CustErr: 'static, diff --git a/server_fn/src/codec/url.rs b/server_fn/src/codec/url.rs index fb298d280..e133066e2 100644 --- a/server_fn/src/codec/url.rs +++ b/server_fn/src/codec/url.rs @@ -1,8 +1,9 @@ use super::{Encoding, FromReq, IntoReq}; -use crate::error::ServerFnError; -use crate::request::{ClientReq, Req}; -use serde::de::DeserializeOwned; -use serde::Serialize; +use crate::{ + error::ServerFnError, + request::{ClientReq, Req}, +}; +use serde::{de::DeserializeOwned, Serialize}; /// Pass arguments as a URL-encoded query string of a `GET` request. pub struct GetUrl; @@ -19,9 +20,13 @@ where Request: ClientReq, T: Serialize + Send, { - fn into_req(self, path: &str, accepts: &str) -> Result> { - let data = - serde_qs::to_string(&self).map_err(|e| ServerFnError::Serialization(e.to_string()))?; + fn into_req( + self, + path: &str, + accepts: &str, + ) -> Result> { + let data = serde_qs::to_string(&self) + .map_err(|e| ServerFnError::Serialization(e.to_string()))?; Request::try_new_get(path, accepts, GetUrl::CONTENT_TYPE, &data) } } @@ -48,9 +53,13 @@ where Request: ClientReq, T: Serialize + Send, { - fn into_req(self, path: &str, accepts: &str) -> Result> { - let qs = - serde_qs::to_string(&self).map_err(|e| ServerFnError::Serialization(e.to_string()))?; + fn into_req( + self, + path: &str, + accepts: &str, + ) -> Result> { + let qs = serde_qs::to_string(&self) + .map_err(|e| ServerFnError::Serialization(e.to_string()))?; Request::try_new_post(path, accepts, PostUrl::CONTENT_TYPE, qs) } } diff --git a/server_fn/src/middleware/mod.rs b/server_fn/src/middleware/mod.rs index 1f16ec299..7c28720e7 100644 --- a/server_fn/src/middleware/mod.rs +++ b/server_fn/src/middleware/mod.rs @@ -13,19 +13,23 @@ impl BoxedService { } pub trait Service { - fn run(&mut self, req: Request) -> Pin + Send>>; + fn run( + &mut self, + req: Request, + ) -> Pin + Send>>; } #[cfg(feature = "axum")] mod axum { + use super::{BoxedService, Service}; use crate::{response::Res, ServerFnError}; use axum::body::Body; use http::{Request, Response}; - use std::fmt::{Debug, Display}; - use std::future::Future; - use std::pin::Pin; - - use super::{BoxedService, Service}; + use std::{ + fmt::{Debug, Display}, + future::Future, + pin::Pin, + }; impl super::Service, Response> for S where @@ -47,11 +51,18 @@ mod axum { } } - impl tower::Service> for BoxedService, Response> { + impl tower::Service> + for BoxedService, Response> + { type Response = Response; type Error = ServerFnError; - type Future = - Pin> + Send>>; + type Future = Pin< + Box< + dyn std::future::Future< + Output = Result, + > + Send, + >, + >; fn poll_ready( &mut self, @@ -68,7 +79,10 @@ mod axum { impl super::Layer, Response> for L where - L: tower_layer::Layer, Response>> + Sync + Send + 'static, + L: tower_layer::Layer, Response>> + + Sync + + Send + + 'static, L::Service: Service, Response> + Send + 'static, { fn layer( @@ -87,8 +101,11 @@ mod actix { ServerFnError, }; use actix_web::{HttpRequest, HttpResponse}; - use std::fmt::{Debug, Display}; - use std::{future::Future, pin::Pin}; + use std::{ + fmt::{Debug, Display}, + future::Future, + pin::Pin, + }; impl super::Service for S where @@ -96,7 +113,10 @@ mod actix { S::Future: Send + 'static, S::Error: Into + Debug + Display + 'static, { - fn run(&mut self, req: HttpRequest) -> Pin + Send>> { + fn run( + &mut self, + req: HttpRequest, + ) -> Pin + Send>> { let inner = self.call(req); Box::pin(async move { inner.await.unwrap_or_else(|e| { diff --git a/server_fn/src/redirect.rs b/server_fn/src/redirect.rs index 42fc80524..67a9cfec6 100644 --- a/server_fn/src/redirect.rs +++ b/server_fn/src/redirect.rs @@ -1,6 +1,7 @@ use std::sync::OnceLock; -static REDIRECT_HOOK: OnceLock> = OnceLock::new(); +static REDIRECT_HOOK: OnceLock> = + OnceLock::new(); pub fn set_redirect_hook(hook: impl Fn(&str) + Send + Sync + 'static) { REDIRECT_HOOK.set(Box::new(hook)); diff --git a/server_fn/src/request/axum.rs b/server_fn/src/request/axum.rs index 457fe650f..41f323062 100644 --- a/server_fn/src/request/axum.rs +++ b/server_fn/src/request/axum.rs @@ -33,11 +33,12 @@ impl Req for Request { fn try_into_stream( self, - ) -> Result> + Send, ServerFnError> - { - Ok(self - .into_body() - .into_data_stream() - .map(|chunk| chunk.map_err(|e| ServerFnError::Deserialization(e.to_string())))) + ) -> Result< + impl Stream> + Send, + ServerFnError, + > { + Ok(self.into_body().into_data_stream().map(|chunk| { + chunk.map_err(|e| ServerFnError::Deserialization(e.to_string())) + })) } } diff --git a/server_fn/src/request/browser.rs b/server_fn/src/request/browser.rs index f985f1ef4..228feee1d 100644 --- a/server_fn/src/request/browser.rs +++ b/server_fn/src/request/browser.rs @@ -1,6 +1,5 @@ -use crate::error::ServerFnError; - use super::ClientReq; +use crate::error::ServerFnError; use bytes::Bytes; pub use gloo_net::http::Request; use js_sys::Uint8Array; diff --git a/server_fn/src/request/mod.rs b/server_fn/src/request/mod.rs index ee5a3f60d..500b853ef 100644 --- a/server_fn/src/request/mod.rs +++ b/server_fn/src/request/mod.rs @@ -59,16 +59,22 @@ where fn to_content_type(&self) -> Option; /// Attempts to extract the body of the request into [`Bytes`]. - fn try_into_bytes(self) -> impl Future>> + Send; + fn try_into_bytes( + self, + ) -> impl Future>> + Send; /// Attempts to convert the body of the request into a string. - fn try_into_string(self) - -> impl Future>> + Send; + fn try_into_string( + self, + ) -> impl Future>> + Send; /// Attempts to convert the body of the request into a string. fn try_into_stream( self, - ) -> Result> + Send, ServerFnError>; + ) -> Result< + impl Stream> + Send, + ServerFnError, + >; } /// A mocked request type that can be used in place of the actual server request, @@ -84,20 +90,26 @@ impl Req for BrowserMockReq { unreachable!() } - fn try_into_bytes(self) -> impl Future>> + Send { + fn try_into_bytes( + self, + ) -> impl Future>> + Send + { async { unreachable!() } } fn try_into_string( self, - ) -> impl Future>> + Send { + ) -> impl Future>> + Send + { async { unreachable!() } } fn try_into_stream( self, - ) -> Result> + Send, ServerFnError> - { + ) -> Result< + impl Stream> + Send, + ServerFnError, + > { Ok(futures::stream::once(async { unreachable!() })) } } diff --git a/server_fn/src/request/reqwest.rs b/server_fn/src/request/reqwest.rs index b03a26db4..c705f966e 100644 --- a/server_fn/src/request/reqwest.rs +++ b/server_fn/src/request/reqwest.rs @@ -1,12 +1,10 @@ -use std::sync::OnceLock; - -use crate::error::ServerFnError; - use super::ClientReq; +use crate::error::ServerFnError; use bytes::Bytes; use once_cell::sync::Lazy; use reqwest::header::{ACCEPT, CONTENT_TYPE}; pub use reqwest::{multipart::Form, Client, Method, Request, Url}; +use std::sync::OnceLock; pub(crate) static CLIENT: Lazy = Lazy::new(Client::new); static ROOT_URL: OnceLock<&'static str> = OnceLock::new(); @@ -34,8 +32,8 @@ impl ClientReq for Request { query: &str, ) -> Result> { let url = format!("{}{}", get_server_url(), path); - let mut url = - Url::try_from(url.as_str()).map_err(|e| ServerFnError::Request(e.to_string()))?; + let mut url = Url::try_from(url.as_str()) + .map_err(|e| ServerFnError::Request(e.to_string()))?; url.set_query(Some(query)); let req = CLIENT .get(url) diff --git a/server_fn/src/response/actix.rs b/server_fn/src/response/actix.rs index 9472113ce..97581999d 100644 --- a/server_fn/src/response/actix.rs +++ b/server_fn/src/response/actix.rs @@ -1,6 +1,9 @@ use super::Res; use crate::error::ServerFnError; -use actix_web::{http::header, http::StatusCode, HttpResponse}; +use actix_web::{ + http::{header, StatusCode}, + HttpResponse, +}; use bytes::Bytes; use futures::Stream; use send_wrapper::SendWrapper; @@ -18,7 +21,10 @@ impl Res for ActixResponse where CustErr: Display, { - fn try_from_string(content_type: &str, data: String) -> Result> { + fn try_from_string( + content_type: &str, + data: String, + ) -> Result> { let mut builder = HttpResponse::build(StatusCode::OK); Ok(ActixResponse(SendWrapper::new( builder @@ -27,7 +33,10 @@ where ))) } - fn try_from_bytes(content_type: &str, data: Bytes) -> Result> { + fn try_from_bytes( + content_type: &str, + data: Bytes, + ) -> Result> { let mut builder = HttpResponse::build(StatusCode::OK); Ok(ActixResponse(SendWrapper::new( builder @@ -38,7 +47,8 @@ where fn error_response(err: ServerFnError) -> Self { ActixResponse(SendWrapper::new( - HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).body(err.to_string()), + HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR) + .body(err.to_string()), )) } diff --git a/server_fn/src/response/browser.rs b/server_fn/src/response/browser.rs index 8132ae881..d1d5ebfdc 100644 --- a/server_fn/src/response/browser.rs +++ b/server_fn/src/response/browser.rs @@ -1,6 +1,5 @@ -use crate::error::ServerFnError; - use super::ClientRes; +use crate::error::ServerFnError; use bytes::Bytes; use futures::{Stream, StreamExt}; pub use gloo_net::http::Response; @@ -14,7 +13,8 @@ pub struct BrowserResponse(pub(crate) SendWrapper); impl ClientRes for BrowserResponse { fn try_into_string( self, - ) -> impl Future>> + Send { + ) -> impl Future>> + Send + { // the browser won't send this async work between threads (because it's single-threaded) // so we can safely wrap this SendWrapper::new(async move { @@ -25,7 +25,10 @@ impl ClientRes for BrowserResponse { }) } - fn try_into_bytes(self) -> impl Future>> + Send { + fn try_into_bytes( + self, + ) -> impl Future>> + Send + { // the browser won't send this async work between threads (because it's single-threaded) // so we can safely wrap this SendWrapper::new(async move { diff --git a/server_fn/src/response/http.rs b/server_fn/src/response/http.rs index 1731f3715..09844e72b 100644 --- a/server_fn/src/response/http.rs +++ b/server_fn/src/response/http.rs @@ -10,7 +10,10 @@ impl Res for Response where CustErr: Send + Sync + Debug + Display + 'static, { - fn try_from_string(content_type: &str, data: String) -> Result> { + fn try_from_string( + content_type: &str, + data: String, + ) -> Result> { let builder = http::Response::builder(); builder .status(200) @@ -19,7 +22,10 @@ where .map_err(|e| ServerFnError::Response(e.to_string())) } - fn try_from_bytes(content_type: &str, data: Bytes) -> Result> { + fn try_from_bytes( + content_type: &str, + data: Bytes, + ) -> Result> { let builder = http::Response::builder(); builder .status(200) @@ -30,9 +36,12 @@ where fn try_from_stream( content_type: &str, - data: impl Stream>> + Send + 'static, + data: impl Stream>> + + Send + + 'static, ) -> Result> { - let body = Body::from_stream(data.map(|n| n.map_err(ServerFnErrorErr::from))); + let body = + Body::from_stream(data.map(|n| n.map_err(ServerFnErrorErr::from))); let builder = http::Response::builder(); builder .status(200) diff --git a/server_fn/src/response/mod.rs b/server_fn/src/response/mod.rs index d58c94fee..e49f58e54 100644 --- a/server_fn/src/response/mod.rs +++ b/server_fn/src/response/mod.rs @@ -18,15 +18,23 @@ where Self: Sized, { /// Attempts to convert a UTF-8 string into an HTTP response. - fn try_from_string(content_type: &str, data: String) -> Result>; + fn try_from_string( + content_type: &str, + data: String, + ) -> Result>; /// Attempts to convert a binary blob represented as bytes into an HTTP response. - fn try_from_bytes(content_type: &str, data: Bytes) -> Result>; + fn try_from_bytes( + content_type: &str, + data: Bytes, + ) -> Result>; /// Attempts to convert a stream of bytes into an HTTP response. fn try_from_stream( content_type: &str, - data: impl Stream>> + Send + 'static, + data: impl Stream>> + + Send + + 'static, ) -> Result>; fn error_response(err: ServerFnError) -> Self; @@ -35,11 +43,14 @@ where /// Represents the response as received by the client. pub trait ClientRes { /// Attempts to extract a UTF-8 string from an HTTP response. - fn try_into_string(self) - -> impl Future>> + Send; + fn try_into_string( + self, + ) -> impl Future>> + Send; /// Attempts to extract a binary blob from an HTTP response. - fn try_into_bytes(self) -> impl Future>> + Send; + fn try_into_bytes( + self, + ) -> impl Future>> + Send; /// Attempts to extract a binary stream from an HTTP response. fn try_into_stream( @@ -64,11 +75,17 @@ pub trait ClientRes { pub struct BrowserMockRes; impl Res for BrowserMockRes { - fn try_from_string(content_type: &str, data: String) -> Result> { + fn try_from_string( + content_type: &str, + data: String, + ) -> Result> { unreachable!() } - fn try_from_bytes(content_type: &str, data: Bytes) -> Result> { + fn try_from_bytes( + content_type: &str, + data: Bytes, + ) -> Result> { unreachable!() }