pub trait Header {
// Required methods
fn name() -> &'static HeaderName;
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
where Self: Sized,
I: Iterator<Item = &'i HeaderValue>;
fn encode<E: Extend<HeaderValue>>(&self, values: &mut E);
// Provided method
fn encode_to_value(&self) -> HeaderValue { ... }
}Expand description
A trait for any object that will represent a header field and value.
This trait represents the construction and identification of headers, and contains trait-object unsafe methods.
Required Methods§
Sourcefn name() -> &'static HeaderName
fn name() -> &'static HeaderName
The name of this header.
Sourcefn decode<'i, I>(values: &mut I) -> Result<Self, Error>
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
Decode this type from an iterator of HeaderValues.
Sourcefn encode<E: Extend<HeaderValue>>(&self, values: &mut E)
fn encode<E: Extend<HeaderValue>>(&self, values: &mut E)
Encode this type to a HeaderValue, and add it to a container
which has HeaderValue type as each element.
This function should be infallible. Any errors converting to a
HeaderValue should have been caught when parsing or constructing
this value.
Provided Methods§
Sourcefn encode_to_value(&self) -> HeaderValue
fn encode_to_value(&self) -> HeaderValue
Encode this Header to HeaderValue.
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.