Response

Struct Response 

Source
pub struct Response<B = Body> { /* private fields */ }
Expand description

An HTTP Response

Implementations§

Source§

impl<B> Response<B>

Source

pub fn new() -> Response<B>

Constructs a default response

Source

pub fn version(&self) -> HttpVersion

Get the HTTP version of this response.

Source

pub fn headers(&self) -> &Headers

Get the headers from the response.

Source

pub fn headers_mut(&mut self) -> &mut Headers

Get a mutable reference to the headers.

Source

pub fn status(&self) -> StatusCode

Get the status from the server.

Source

pub fn set_status(&mut self, status: StatusCode)

Set the StatusCode for this response.

Source

pub fn with_status(self, status: StatusCode) -> Response<B>

Set the status and move the Response.

Useful for the “builder-style” pattern.

Source

pub fn with_header<H>(self, header: H) -> Response<B>
where H: Header,

Set a header and move the Response.

Useful for the “builder-style” pattern.

Source

pub fn with_headers(self, headers: Headers) -> Response<B>

Set the headers and move the Response.

Useful for the “builder-style” pattern.

Source

pub fn set_body<T>(&mut self, body: T)
where T: Into<B>,

Set the body.

Source

pub fn with_body<T>(self, body: T) -> Response<B>
where T: Into<B>,

Set the body and move the Response.

Useful for the “builder-style” pattern.

Source

pub fn body_ref(&self) -> Option<&B>

Read the body.

Source§

impl Response

Source

pub fn body(self) -> Body

Take the Body of this response.

Trait Implementations§

Source§

impl Debug for Response

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<B> Default for Response<B>

Available on non-crate feature raw_status only.
Source§

fn default() -> Response<B>

Returns the “default value” for a type. Read more
Source§

impl Responder for Response

Auto Trait Implementations§

§

impl<B> Freeze for Response<B>
where B: Freeze,

§

impl<B = Body> !RefUnwindSafe for Response<B>

§

impl<B> Send for Response<B>
where B: Send,

§

impl<B = Body> !Sync for Response<B>

§

impl<B> Unpin for Response<B>
where B: Unpin,

§

impl<B = Body> !UnwindSafe for Response<B>

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.