Trait HttpHeaders

Source
pub trait HttpHeaders {
    // Required methods
    fn get(&self, name: impl AsHeaderName) -> Option<HeaderValue>;
    fn get_all(
        &self,
        name: impl AsHeaderName,
    ) -> impl Iterator<Item = HeaderValue>;
    fn has(&self, name: impl AsHeaderName) -> bool;
    fn iter(&self) -> impl Iterator<Item = (HeaderName, HeaderValue)>;
}
Expand description

Shared methods between the owned and borrowed header types.

Required Methods§

Source

fn get(&self, name: impl AsHeaderName) -> Option<HeaderValue>

Get the value associated with the given name. If there are multiple values associated with the name, then the first one is returned. Use get_all to get all values associated with a given name. Returns None if there are no values associated with the name.

Source

fn get_all(&self, name: impl AsHeaderName) -> impl Iterator<Item = HeaderValue>

Get all of the values corresponding to a name. If the name is not present, an empty list is returned. However, if the name is present but empty, this is represented by a list with one or more empty values present.

Source

fn has(&self, name: impl AsHeaderName) -> bool

Returns true if the map contains a value for the specified name.

Source

fn iter(&self) -> impl Iterator<Item = (HeaderName, HeaderValue)>

An iterator visiting all name-value pairs.

The iteration order is arbitrary, but consistent across platforms for the same crate version. Each name will be yielded once per associated value. So, if a name has 3 associated values, it will be yielded 3 times.

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.

Implementors§