[][src]Struct viaduct::Response

pub struct Response {
    pub request_method: Method,
    pub url: Url,
    pub status: u16,
    pub headers: Headers,
    pub body: Vec<u8>,
}

A response from the server.

Fields

request_method: Method

The method used to request this response.

url: Url

The URL of this response.

status: u16

The HTTP Status code of this response.

headers: Headers

The headers returned with this response.

body: Vec<u8>

The body of the response. Note that responses with binary bodies are currently unsupported.

Implementations

impl Response[src]

pub fn json<'a, T>(&'a self) -> Result<T, Error> where
    T: Deserialize<'a>, 
[src]

Parse the body as JSON.

pub fn text(&self) -> Cow<'_, str>[src]

Get the body as a string. Assumes UTF-8 encoding. Any non-utf8 bytes are replaced with the replacement character.

pub fn is_success(&self) -> bool[src]

Returns true if the status code is in the interval [200, 300).

pub fn is_server_error(&self) -> bool[src]

Returns true if the status code is in the interval [500, 600).

pub fn is_client_error(&self) -> bool[src]

Returns true if the status code is in the interval [400, 500).

pub fn require_success(self) -> Result<Self, UnexpectedStatus>[src]

Returns an [UnexpectedStatus] error if self.is_success() is false, otherwise returns Ok(self).

Trait Implementations

impl Clone for Response[src]

impl Debug for Response[src]

impl PartialEq<Response> for Response[src]

impl StructuralPartialEq for Response[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.