[][src]Struct http_header::Header

pub struct Header {
    pub status_line: (Data<Ascii>, Data<Ascii>, Data<Ascii>),
    pub fields: HashMap<Data<HeaderFieldKey>, Data<Ascii>>,
}

A generic HTTP/1.* header implementation

Can be converted into a RequestHeader/ResponseHeader using the TryFrom/TryInto-traits

Fields

status_line: (Data<Ascii>, Data<Ascii>, Data<Ascii>)

The header status line

fields: HashMap<Data<HeaderFieldKey>, Data<Ascii>>

The header fields

Methods

impl Header[src]

pub fn scan(data: &[u8]) -> Option<(&[u8], &[u8])>[src]

Checks if data starts with a header-like structure and returns either Some((header, body)) or None if no header-like structure was found

pub fn read(source: impl Read, buf: &mut [u8]) -> Result<Option<usize>, Error>[src]

Reads from source into buf until a HTTP-header-end is matched or buf is filled completely

Returns either Some(header_len) if the header end has been matched or None if buf has been filled completely without a match.

pub fn parse(bytes: &[u8]) -> Result<Self, HttpError>[src]

Parses a HTTP request header from bytes

pub fn write(&self, sink: impl WriteExt) -> Result<usize, Error>[src]

Serializes and writes the header to sink and returns the amount of bytes written

pub fn to_vec(&self) -> Vec<u8>[src]

Serializes the header into a vector

Trait Implementations

impl AsRef<Header> for RequestHeader[src]

impl AsRef<Header> for ResponseHeader[src]

impl Clone for Header[src]

impl From<RequestHeader> for Header[src]

impl From<ResponseHeader> for Header[src]

impl Debug for Header[src]

impl TryFrom<Header> for RequestHeader[src]

type Error = HttpError

The type returned in the event of a conversion error.

fn try_from(header: Header) -> Result<Self, Self::Error>[src]

Tries to create a RequestHeader from a Header

impl TryFrom<Header> for ResponseHeader[src]

type Error = HttpError

The type returned in the event of a conversion error.

fn try_from(header: Header) -> Result<Self, Self::Error>[src]

Tries to create a RequestHeader from a Header

Auto Trait Implementations

impl Sync for Header

impl Send for Header

impl Unpin for Header

impl UnwindSafe for Header

impl RefUnwindSafe for Header

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

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.

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

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

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