pub struct Response { /* private fields */ }Expand description
A response from a fetch request. Headers are available immediately; the body streams from the socket as it is read.
Implementations§
Source§impl Response
impl Response
Sourcepub async fn text(&self) -> Result<String>
pub async fn text(&self) -> Result<String>
Get the response body as text. Malformed UTF-8 is replaced rather
than rejected, matching the browser’s Response.text().
Sourcepub async fn json<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
pub async fn json<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
Get the response body as JSON
Sourcepub async fn json_value(&self) -> Result<Value>
pub async fn json_value(&self) -> Result<Value>
Get the response body as a dynamic JSON value
Sourcepub fn error_for_status(self) -> Result<Self>
pub fn error_for_status(self) -> Result<Self>
Ensure the response was successful, returning an error if not
Sourcepub fn stream_reader(&self) -> Result<StreamReader>
pub fn stream_reader(&self) -> Result<StreamReader>
Get a stream reader for reading chunks from the response as they
arrive. Takes over the body, so it can’t be read from self again.
Auto Trait Implementations§
impl !Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
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