Struct Response

Source
pub struct Response<'a> { /* private fields */ }
Expand description

Represents a single HTTP-Request

Implementations§

Source§

impl<'a> Response<'a>

Source

pub fn new( protocol: &'a str, status_code: StatusCode, headers: Headers<'a>, body: Vec<u8>, ) -> Self

Creates a new Response with the given Data as its inital State

Source

pub fn serialize(&self) -> (Vec<u8>, &[u8])

Serialzes the Response and returns the Data as a tuple of form (HTTP-Head, HTTP-Body)

Source

pub fn protocol(&self) -> &str

Returns the Protocol of the Response

Source

pub fn status_code(&self) -> &StatusCode

Returns the StatusCode of the Response

Source

pub fn headers(&self) -> &Headers<'a>

Returns the Headers of the Response

Source

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

Returns the Body of the Response

Source

pub fn add_header<'b, K, V>(&mut self, key: K, value: V)
where K: Into<HeaderKey<'a>>, V: Into<HeaderValue<'a>>, 'b: 'a,

Adds the Key-Value Pair as a new Header to the Response or replaces the old Value of the Header if it already existed on the Response

Source

pub fn set_body(&mut self, n_body: Vec<u8>)

Replaces the old Body of the Response with the new given Body and updates the Content-Length Header as well with the new Length

Source

pub fn is_chunked(&self) -> bool

Checks if the Response is send using Transfer-Encoding: Chunked

Source

pub fn to_owned<'refed, 'owned>(&'refed self) -> Response<'owned>

Clones the entire Response to produce a new indepandent Response

Trait Implementations§

Source§

impl<'a> Debug for Response<'a>

Source§

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

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

impl<'a> PartialEq for Response<'a>

Source§

fn eq(&self, other: &Response<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for Response<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Response<'a>

§

impl<'a> RefUnwindSafe for Response<'a>

§

impl<'a> Send for Response<'a>

§

impl<'a> Sync for Response<'a>

§

impl<'a> Unpin for Response<'a>

§

impl<'a> UnwindSafe for Response<'a>

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.