pub struct Response { /* private fields */ }
Expand description
A Response to a submitted Request
.
Implementations
sourceimpl Response
impl Response
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the StatusCode
of this Response
.
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Get a mutable reference to the Headers
of this Response
.
sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Get the content-length of this response, if known.
Reasons it may not be known:
- The server didn’t send a
content-length
header. - The response is compressed and automatically decoded (thus changing the actual decoded length).
sourcepub async fn json<T: DeserializeOwned>(self) -> Result<T>
This is supported on crate feature json
only.
pub async fn json<T: DeserializeOwned>(self) -> Result<T>
This is supported on crate feature
json
only.Try to deserialize the response body as JSON.
sourcepub fn error_for_status(self) -> Result<Self>
pub fn error_for_status(self) -> Result<Self>
Turn a response into an error if the server returned an error.
sourcepub fn error_for_status_ref(&self) -> Result<&Self>
pub fn error_for_status_ref(&self) -> Result<&Self>
Turn a reference to a response into an error if the server returned an error.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Response
impl !Send for Response
impl !Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more