Struct ResponseBuilder

Source
pub struct ResponseBuilder { /* private fields */ }
Expand description

Build a response

Implementations§

Source§

impl ResponseBuilder

Source

pub fn new() -> Self

Source

pub fn empty_500() -> Self

Set the builer to build a response with an empty body and 500 status code

Source

pub fn empty_200() -> Self

Set the builer to build a response with an empty body and 200 status code

Source

pub fn empty_400() -> Self

Set the builer to build a response with an empty body and 400 status code

Source

pub fn code(self, code: i32) -> Self

Set the the status code of the response

Source

pub fn reason(self, reason: String) -> Self

Set the reason of the response

Source

pub fn version(self, version: Version) -> Self

Set the HTTP version of the response

Source

pub fn headers(self, headers: Headers) -> Self

Set the header object for the response

Source

pub fn header(self, key: &str, value: &str) -> Self

Set a single header for the response

Source

pub fn content_type(self, content_type: &str) -> Self

Set the “Content_Type” header of the response

Source

pub fn body(self, body: &[u8]) -> Self

Set the body as a byte slice of the response

Source

pub fn status(self, status: Reason) -> Self

Set the status of the response (code + reason phrase)

Source

pub fn build(self) -> Result<Response, BuildError>

Build the response from the provided information If some informations are missing, BuildError will occur

Trait Implementations§

Source§

impl Default for ResponseBuilder

Source§

fn default() -> Self

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

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.