pub struct Response<T> {
    pub status: u32,
    pub headers: HashMap<String, String>,
    pub body: T,
}
Expand description

HTTP responses structure containing response data and headers.

By default the send() function of the Request structure will return a Response<Vec<u8>>. Convenience helpers exist for decoding a string via Response::as_string or to a serde-compatible type with Response::as_json (if the json-feature is enabled).

Fields

status: u32

HTTP status code of the response.

headers: HashMap<String, String>

HTTP headers returned from the remote.

body: T

Body data from the HTTP response.

Implementations

Check whether the status code of this HTTP response is a success (i.e. in the 200-299 range).

Check whether a request succeeded using Request::is_success and let users provide a closure that creates a custom error from the request if it did not.

This function exists for convenience to avoid having to write repetitive if !response.is_success() { ... } blocks.

Attempt to parse the HTTP response body as a UTF-8 encoded string.

Attempt to deserialize the HTTP response body from JSON.

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.