[−][src]Struct viaduct::Response
A response from the server.
Fields
request_method: MethodThe method used to request this response.
url: UrlThe URL of this response.
status: u16The HTTP Status code of this response.
headers: HeadersThe 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]
T: Deserialize<'a>,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,