pub trait FromHeaders: Sized {
type Error: Error + Send + Sync + 'static;
// Required methods
fn header_names() -> &'static [&'static str];
fn from_headers(headers: &Headers) -> Result<Option<Self>, Self::Error>;
}Expand description
Extract a value from the Headers collection.
The FromHeaders::from_headers() method is usually used implicitly, through Headers::get() or Headers::get_optional().
Required Associated Types§
Required Methods§
Sourcefn header_names() -> &'static [&'static str]
fn header_names() -> &'static [&'static str]
Gets a list of the header names that FromHeaders::from_headers expects.
Used by Headers::get() to generate an error if the headers are not present.
Sourcefn from_headers(headers: &Headers) -> Result<Option<Self>, Self::Error>
fn from_headers(headers: &Headers) -> Result<Option<Self>, Self::Error>
Extracts the value from the provided Headers collection.
This method returns one of the following three values:
Ok(Some(...))if the relevant headers are present and could be parsed into the value.Ok(None)if the relevant headers are not present, so no attempt to parse them can be made.Err(...)if an error occurred when trying to parse the headers. This likely indicates that the headers are present but invalid.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".