pub struct HttpResponse(/* private fields */);Expand description
A struct that represents an HTTP response.
Implementations§
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the status code of the HTTP response.
Sourcepub fn text(self) -> Result<String, FromUtf8Error>
pub fn text(self) -> Result<String, FromUtf8Error>
Attempts to convert the HTTP response body into a UTF-8 encoded String.
This method takes ownership of the HttpResponse and returns a Result<String, std::string::FromUtf8Error>.
It attempts to interpret the bytes in the body as a valid UTF-8 sequence.
Sourcepub fn json<'de, T>(&'de self) -> Result<T, JsonDeserializeError>where
T: Deserialize<'de>,
pub fn json<'de, T>(&'de self) -> Result<T, JsonDeserializeError>where
T: Deserialize<'de>,
Attempts to deserialize the HTTP response body as JSON.
This method takes ownership of the HttpResponse and returns a Result<serde_json::Value, serde_json::Error>.
It attempts to interpret the bytes in the body as valid JSON. The conversion is successful if the byte slice represents a valid JSON value according to the JSON specification.
Auto Trait Implementations§
impl Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnwindSafe for HttpResponse
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