pub trait Header {
// Required methods
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§
Sourcefn name() -> &'static HeaderName
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
.
Sourcefn from_values<'a>(
values: &mut ValueIter<'a, HeaderValue>,
) -> Result<Option<Self>, Error>where
Self: Sized,
fn from_values<'a>(
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.
Sourcefn to_values(&self, values: &mut ToValues<'_>)
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.