Trait typed_headers::Header [−][src]
pub trait Header { fn name() -> &'static HeaderName; fn from_values<'a>(
values: &mut ValueIter<'a, HeaderValue>
) -> Result<Option<Self>, Error>
where
Self: Sized; fn to_values(&self, values: &mut ToValues); }
Required Methods
fn name() -> &'static HeaderName
Returns the name of this header.
The http
crate provides constants for all standard header names. Implementations for
nonstandard headers can use the lazy_static
crate to obtain a static reference to a
HeaderName
.
fn from_values<'a>(
values: &mut ValueIter<'a, HeaderValue>
) -> Result<Option<Self>, Error> where
Self: Sized,
values: &mut ValueIter<'a, HeaderValue>
) -> Result<Option<Self>, Error> where
Self: Sized,
Parses the header from the raw value bytes.
The iterator may be empty, which indicates that the header was not present, and Ok(None)
should be returned.
If the iterator is not exhausted when this function returns, it will be treated as a parse error.
fn to_values(&self, values: &mut ToValues)
Serializes the header to raw values.
Each call to values.append
adds a header entry. Almost all headers should only append a
single value. Set-Cookie
is a rare exception.
This method is infallible. Header implementations should ensure at construction time that they will be able to successfully serialize.
Implementors
impl Header for Accept
impl Header for AcceptEncoding
impl Header for Allow
impl Header for Authorization
impl Header for ContentEncoding
impl Header for ContentLength
impl Header for ContentType
impl Header for Host
impl Header for ProxyAuthorization
impl Header for RetryAfter