[][src]Struct http_str::Response

pub struct Response<'a> {
    pub response: &'a str,
    pub version: &'a str,
    pub status_phrase: &'a str,
    pub headers_map: BTreeMap<&'a str, Vec<&'a str>>,
    pub body: &'a str,
    pub status: &'a str,
    // some fields omitted
}

Fields

response: &'a strversion: &'a strstatus_phrase: &'a strheaders_map: BTreeMap<&'a str, Vec<&'a str>>body: &'a strstatus: &'a str

Methods

impl<'a> Response<'a>[src]

pub fn new(
    version: &'a str,
    status: u16,
    headers_map: BTreeMap<&'a str, Vec<&'a str>>,
    body: &'a str,
    response_out: &'a mut String
) -> Pin<Box<Self>>
[src]

Creates a new Response from their http version,a status code,a map which hash the values of the headers in a vec by their name, the body of the response and a mutable reference to an empty String(this might change in the future 'cause it is a lifetime hack but one notable advantange of this is the freedom of choose the capacity of the String based in your application).

After that,you can access the field response for the full response String as well the headers_map, status, status_phrase, body and the version string slices of the response. The previous identical data passed to this function get dropped.

pub fn from_bytes(bytes: &'a [u8]) -> Pin<Box<Self>>[src]

Creates a new Response from a slice of utf8 encoded bytes, useful when building client code.

pub fn get_phrase(status: u16) -> &'a str[src]

Get the phrase related to the http status code from a big,lazy initialized,HashMap based on the official codes documented in wikipedia.

pub fn as_bytes(&self) -> &'a [u8][src]

Trait Implementations

impl<'a> Display for Response<'a>[src]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.