Struct reqwest::Response

source ·
pub struct Response { /* private fields */ }
Expand description

A Response to a submitted Request.

Implementations§

source§

impl Response

source

pub fn status(&self) -> StatusCode

Get the StatusCode of this Response.

source

pub fn headers(&self) -> &HeaderMap

Get the Headers of this Response.

source

pub fn headers_mut(&mut self) -> &mut HeaderMap

Get a mutable reference to the Headers of this Response.

source

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).
source

pub fn url(&self) -> &Url

Get the final Url of this Response.

source

pub async fn json<T: DeserializeOwned>(self) -> Result<T>

Available on crate feature json only.

Try to deserialize the response body as JSON.

source

pub async fn text(self) -> Result<String>

Get the response text.

source

pub async fn bytes(self) -> Result<Bytes>

Get the response as bytes

source

pub fn bytes_stream(self) -> impl Stream<Item = Result<Bytes>>

Convert the response into a Stream of Bytes from the body.

source

pub fn error_for_status(self) -> Result<Self>

Turn a response into an error if the server returned an error.

source

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§

source§

impl Debug for Response

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.