Skip to main content

Response

Struct Response 

Source
pub struct Response {
    pub status: u16,
    pub headers: Headers,
    pub body: Body,
}

Fields§

§status: u16§headers: Headers§body: Body

Implementations§

Source§

impl Response

Source

pub fn new(status: u16) -> Response

Source

pub fn bytes(status: u16, content_type: &str, body: Vec<u8>) -> Response

Source

pub fn text(status: u16, s: &str) -> Response

Source

pub fn json(status: u16, v: &Value) -> Response

Source

pub fn header(self, name: &str, value: &str) -> Response

Source

pub fn body_bytes(&self) -> &[u8] ⓘ

the body bytes (client side: always Bytes)

Source

pub fn body_json(&self, limits: Limits) -> Option<Value>

Trait Implementations§

Source§

impl Debug for Response

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Response

§

impl !Sync for Response

§

impl !UnwindSafe for Response

§

impl Forget for Response

§

impl Freeze for Response
where *const u8 is !null: Freeze, PhantomData<(String, String)>: Freeze, PhantomData<u8>: Freeze, *const dyn FnMut(&mut Vec<u8>) -> bool + Send is !null: Freeze, PhantomData<dyn FnMut(&mut Vec<u8>) -> bool + Send>: Freeze, *const dyn FnOnce(Upgraded) + Send is !null: Freeze, PhantomData<dyn FnOnce(Upgraded) + Send>: Freeze,

§

impl Move for Response

§

impl Send for Response
where RawVecInner: Send, BoxRaw<dyn FnMut(&mut Vec<u8>) -> bool + Send>: Send, BoxRaw<dyn FnOnce(Upgraded) + Send>: Send,

§

impl Unpin for Response
where *const u8 is !null: Unpin, Box<dyn FnMut(&mut Vec<u8>) -> bool + Send>: Unpin, Box<dyn FnOnce(Upgraded) + Send>: Unpin,

§

impl UnsafeUnpin for Response

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.