pub struct TypedResponse<T, E> { /* private fields */ }
Expand description
Holds raw response body, while remembering desired shape of the success (T
)
and failure (E
) variants.
Implementations§
Source§impl<T, E> TypedResponse<T, E>
impl<T, E> TypedResponse<T, E>
Sourcepub async fn try_from_response(response: Response) -> Result<Self>
pub async fn try_from_response(response: Response) -> Result<Self>
Converts reqwest::Response
into TypedResponse<T, E>
Sourcepub fn into_json(self) -> Result<Value, Value>
pub fn into_json(self) -> Result<Value, Value>
Convert this response into Result<serde_json::Value, serde_json::Value>
where Ok
and Err
variants are based on the original HTTP Status
In case the body is not a valid JSON by itself it creates a JSON object
with deserialization error as a string content
Sourcepub fn into_result(self) -> Result<T, E>
pub fn into_result(self) -> Result<T, E>
Convert this response into Result<T, E>
where Ok
and Err
variants
are based on the original HTTP Status and type parameters. In case of
JSON deserialization error it will be converted into E
Trait Implementations§
Source§impl<T: Clone, E: Clone> Clone for TypedResponse<T, E>
impl<T: Clone, E: Clone> Clone for TypedResponse<T, E>
Source§fn clone(&self) -> TypedResponse<T, E>
fn clone(&self) -> TypedResponse<T, E>
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<T, E> !Freeze for TypedResponse<T, E>
impl<T, E> RefUnwindSafe for TypedResponse<T, E>where
T: RefUnwindSafe,
E: RefUnwindSafe,
impl<T, E> Send for TypedResponse<T, E>
impl<T, E> Sync for TypedResponse<T, E>
impl<T, E> Unpin for TypedResponse<T, E>
impl<T, E> UnwindSafe for TypedResponse<T, E>where
T: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more