Response

Struct Response 

Source
pub struct Response {
    pub content: Vec<u8>,
    /* private fields */
}
Expand description

Contains the data of an http response

Fields§

§content: Vec<u8>

Implementations§

Source§

impl Response

Source

pub fn continue() -> Response

Creates an Continue response, with a 100 status code

Source

pub fn switching_protocols() -> Response

Creates an Switching Protocols response, with a 101 status code

Source

pub fn ok() -> Response

Creates an Ok response, with a 200 status code

Source

pub fn created() -> Response

Creates a Created response, with a 201 status code

Source

pub fn accepted() -> Response

Creates an Accepted response, with a 202 status code

Source

pub fn non_authoritative_information() -> Response

Creates a Non-Authoritative Information response, with a 203 status code

Source

pub fn no_content() -> Response

Creates a No Content response, with a 204 status code

Source

pub fn reset_content() -> Response

Creates a Reset Content response, with a 205 status code

Source

pub fn partial_content() -> Response

Creates a Partial Content response, with a 206 status code

Source

pub fn bad_request() -> Response

Creates a Bad Request response, with a 400 status code

Source

pub fn unauthorized() -> Response

Creates an Unauthorized response, with a 401 status code

Source

pub fn payment_required() -> Response

Creates a Payment Required response, with a 402 status code

Source

pub fn forbidden() -> Response

Creates a Forbidden response, with a 403 status code

Source

pub fn not_found() -> Response

Creates a Not Found response, with a 404 status code

Source

pub fn internal_server_error() -> Response

Creates an Internal Server Error response, with a 500 status code

Source

pub fn not_implemented() -> Response

Creates a Not Implemented response, with a 501 status code

Source

pub fn bad_gateway() -> Response

Creates a Bad Gateway response, with a 502 status code

Source

pub fn service_unavailable() -> Response

Creates a Service Unavailable response, with a 503 status code

Source

pub fn new() -> Response

Creates a new response, with defaut response status 200, and a text/html content type

Source

pub fn header<A: Into<String>, B: Into<String>>( self, key: A, value: B, ) -> Response

Inserts a header into the response

Source

pub fn body<T: AsRef<[u8]>>(self, body: T) -> Response

Inserts a body in the response

Source

pub fn status_code(&self) -> u32

Returns the status code contained in the response

Trait Implementations§

Source§

impl<A: Into<String>> From<(u32, A)> for Response

Source§

fn from(source: (u32, A)) -> Response

Converts to this type from the input type.
Source§

impl<A: Into<Response>, B: Into<Response>> Into<Response> for Result<A, B>

Source§

fn into(self) -> Response

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.