pub trait HeaderValues {
Show 28 methods
// Required methods
fn string_value(&self, name: HeaderName) -> Option<&str>;
fn string_values(&self, name: HeaderName) -> Vec<&str>;
fn byte_string_value(&self, name: HeaderName) -> Option<ByteString>;
fn byte_string_values(&self, name: HeaderName) -> Vec<ByteString>;
fn set_value<ValueT>(&mut self, name: HeaderName, value: ValueT)
where ValueT: Into<HeaderValue>;
fn set_into_header_value<ValueT>(&mut self, name: HeaderName, value: ValueT)
where ValueT: IntoHeaderValue;
fn set_string_value(
&mut self,
name: HeaderName,
value: &str,
) -> Result<(), InvalidHeaderValue>;
// Provided methods
fn bool_value(&self, name: HeaderName, default: bool) -> bool { ... }
fn parse_value<FromStrT>(&self, name: HeaderName) -> Option<FromStrT>
where FromStrT: FromStr,
FromStrT::Err: Display { ... }
fn preferences<FormatT>(&self, name: HeaderName) -> Preferences<FormatT>
where FormatT: Clone + Eq + FromStr { ... }
fn duration_value(&self, name: HeaderName) -> Option<Duration> { ... }
fn date_value(&self, name: HeaderName) -> Option<HttpDate> { ... }
fn set_string_values<IteratorT, NameT, ValueT>(
&mut self,
name_value_pairs: IteratorT,
) -> Result<(), InvalidHeaderValue>
where IteratorT: Iterator<Item = (NameT, ValueT)>,
NameT: AsRef<str>,
ValueT: AsRef<str> { ... }
fn set_bool_value(&mut self, name: HeaderName, value: bool) { ... }
fn content_length(&self) -> Option<usize> { ... }
fn content_type(&self) -> Option<MediaType> { ... }
fn accept(&self) -> Preferences<MediaTypeSelector> { ... }
fn accept_encoding(&self) -> Preferences<EncodingHeaderValue> { ... }
fn accept_language(&self) -> Preferences<Language> { ... }
fn if_modified_since(&self) -> Option<HttpDate> { ... }
fn if_none_match(&self) -> Option<ETagMatcher> { ... }
fn if_unmodified_since(&self) -> Option<HttpDate> { ... }
fn if_match(&self) -> Option<ETagMatcher> { ... }
fn authorization_basic(&self) -> Option<(String, String)> { ... }
fn content_encoding(&self) -> EncodingHeaderValue { ... }
fn content_language(&self) -> Option<FastHashSet<Language>> { ... }
fn last_modified(&self) -> Option<HttpDate> { ... }
fn etag(&self) -> Option<ETag> { ... }
}
Expand description
Access header values.
Required Methods§
Sourcefn string_value(&self, name: HeaderName) -> Option<&str>
fn string_value(&self, name: HeaderName) -> Option<&str>
Parse a header value as an ASCII string.
None could mean that there is no such header or that it is not a valid ASCII string.
Sourcefn string_values(&self, name: HeaderName) -> Vec<&str>
fn string_values(&self, name: HeaderName) -> Vec<&str>
Parse all header values as ASCII strings.
Will skip over non-ASCII values.
Sourcefn byte_string_value(&self, name: HeaderName) -> Option<ByteString>
fn byte_string_value(&self, name: HeaderName) -> Option<ByteString>
Parse a header value as an ASCII string.
None could mean that there is no such header or that it is not a valid ASCII string.
Unfortunately this is not zero-copy because HeaderValue does not give us access to its inner Bytes.
Sourcefn byte_string_values(&self, name: HeaderName) -> Vec<ByteString>
fn byte_string_values(&self, name: HeaderName) -> Vec<ByteString>
Parse all header values as ASCII strings.
Will skip over non-ASCII values.
Unfortunately this is not zero-copy because HeaderValue does not give us access to its inner Bytes.
Sourcefn set_value<ValueT>(&mut self, name: HeaderName, value: ValueT)where
ValueT: Into<HeaderValue>,
fn set_value<ValueT>(&mut self, name: HeaderName, value: ValueT)where
ValueT: Into<HeaderValue>,
Set a header value.
Makes sure to remove existing values first.
Sourcefn set_into_header_value<ValueT>(&mut self, name: HeaderName, value: ValueT)where
ValueT: IntoHeaderValue,
fn set_into_header_value<ValueT>(&mut self, name: HeaderName, value: ValueT)where
ValueT: IntoHeaderValue,
Set a header value.
Makes sure to remove existing values first.
Sourcefn set_string_value(
&mut self,
name: HeaderName,
value: &str,
) -> Result<(), InvalidHeaderValue>
fn set_string_value( &mut self, name: HeaderName, value: &str, ) -> Result<(), InvalidHeaderValue>
Set a header string value.
Makes sure to remove existing values first.
Will fail if not an ASCII string.
Provided Methods§
Sourcefn bool_value(&self, name: HeaderName, default: bool) -> bool
fn bool_value(&self, name: HeaderName, default: bool) -> bool
Parse a header value as a boolean (“true” or “false”) or return a default a value.
Sourcefn parse_value<FromStrT>(&self, name: HeaderName) -> Option<FromStrT>
fn parse_value<FromStrT>(&self, name: HeaderName) -> Option<FromStrT>
Parse a header from its ASCII string value.
None could mean that there is no such header or that it is malformed.
Sourcefn preferences<FormatT>(&self, name: HeaderName) -> Preferences<FormatT>
fn preferences<FormatT>(&self, name: HeaderName) -> Preferences<FormatT>
Parse, combine, and sort all header values as Preferences.
Will skip over malformed values.
Sourcefn duration_value(&self, name: HeaderName) -> Option<Duration>
fn duration_value(&self, name: HeaderName) -> Option<Duration>
Parse a header value as a Duration.
None could mean that there is no such header or that it is malformed.
See duration-str.
Sourcefn date_value(&self, name: HeaderName) -> Option<HttpDate>
fn date_value(&self, name: HeaderName) -> Option<HttpDate>
Sourcefn set_string_values<IteratorT, NameT, ValueT>(
&mut self,
name_value_pairs: IteratorT,
) -> Result<(), InvalidHeaderValue>
fn set_string_values<IteratorT, NameT, ValueT>( &mut self, name_value_pairs: IteratorT, ) -> Result<(), InvalidHeaderValue>
Set header string values.
Invalid header names will be skipped.
Makes sure to remove existing values first for each header.
Will fail if a value is not an ASCII string.
Sourcefn set_bool_value(&mut self, name: HeaderName, value: bool)
fn set_bool_value(&mut self, name: HeaderName, value: bool)
Set a boolean header value (“true” or “false”).
Makes sure to remove existing values first.
Sourcefn content_length(&self) -> Option<usize>
fn content_length(&self) -> Option<usize>
Parse the Content-Length
header value.
None could mean that there is no such header or that it is malformed.
Sourcefn content_type(&self) -> Option<MediaType>
fn content_type(&self) -> Option<MediaType>
Parse the Content-Type
header value.
None could mean that there is no such header or that it is malformed.
Sourcefn accept(&self) -> Preferences<MediaTypeSelector>
fn accept(&self) -> Preferences<MediaTypeSelector>
Parse, combine, and sort all Accept
request header values.
Will skip over malformed values.
Sourcefn accept_encoding(&self) -> Preferences<EncodingHeaderValue>
fn accept_encoding(&self) -> Preferences<EncodingHeaderValue>
Parse, combine, and sort all Accept-Encoding
request header values.
Will skip over malformed values.
Sourcefn accept_language(&self) -> Preferences<Language>
fn accept_language(&self) -> Preferences<Language>
Parse, combine, and sort all Accept-Language
request header values.
Note that we convert all subtags to lowercase for comparison efficiency.
Will skip over malformed values.
Sourcefn if_modified_since(&self) -> Option<HttpDate>
fn if_modified_since(&self) -> Option<HttpDate>
Parse the If-Modified-Since
request header value.
None could mean that there is no such header or that it is malformed.
Sourcefn if_none_match(&self) -> Option<ETagMatcher>
fn if_none_match(&self) -> Option<ETagMatcher>
Parse the If-None-Match
request header value.
None could mean that there is no such header or that it is malformed.
Sourcefn if_unmodified_since(&self) -> Option<HttpDate>
fn if_unmodified_since(&self) -> Option<HttpDate>
Parse the If-Unmodified-Since
request header value.
None could mean that there is no such header or that it is malformed.
Sourcefn if_match(&self) -> Option<ETagMatcher>
fn if_match(&self) -> Option<ETagMatcher>
Parse the Authorization
request header value for the Basic
scheme.
Expects UTF-8 strings.
Returns the username and password.
None could mean that there is no such header or that it is malformed.
Sourcefn content_encoding(&self) -> EncodingHeaderValue
fn content_encoding(&self) -> EncodingHeaderValue
Parse the Content-Encoding
response header value.
Defaults to Identity if there is no such header or that is malformed.
Sourcefn content_language(&self) -> Option<FastHashSet<Language>>
fn content_language(&self) -> Option<FastHashSet<Language>>
Parse the Content-Language
response header value.
Note that we convert all subtags to lowercase for comparison efficiency.
Despite the header name, there can be more than one language listed. We will skip over duplicates.
Sourcefn last_modified(&self) -> Option<HttpDate>
fn last_modified(&self) -> Option<HttpDate>
Parse the Last-Modified
response header value.
None could mean that there is no such header or that it is malformed.
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.