Struct awc::http::HeaderMap [−][src]
pub struct HeaderMap { /* fields omitted */ }
Expand description
A set of HTTP headers
HeaderMap
is an multi-map of HeaderName
to values.
Implementations
Create an empty HeaderMap
.
The map will be created without any capacity. This function will not allocate.
Create an empty HeaderMap
with the specified capacity.
The returned map will allocate internal storage in order to hold about
capacity
elements without reallocating. However, this is a “best
effort” as there are usage patterns that could cause additional
allocations before capacity
headers are stored in the map.
More capacity than requested may be allocated.
Returns the number of keys stored in the map.
This number could be be less than or equal to actual headers stored in the map.
Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.
Returns the number of headers the map can hold without reallocating.
This number is an approximation as certain usage patterns could cause additional allocations before the returned capacity is filled.
Reserves capacity for at least additional
more headers to be inserted
into the HeaderMap
.
The header map may reserve more space to avoid frequent reallocations.
Like with with_capacity
, this will be a “best effort” to avoid
allocations until additional
more headers are inserted. Certain usage
patterns could cause additional allocations before the number is
reached.
Returns a reference to the value associated with the key.
If there are multiple values associated with the key, then the first one
is returned. Use get_all
to get all values associated with a given
key. Returns None
if there are no values associated with the key.
Returns a view of all values associated with a key.
The returned view does not incur any allocations and allows iterating
the values associated with the key. See GetAll
for more details.
Returns None
if there are no values associated with the key.
Returns a mutable reference to the value associated with the key.
If there are multiple values associated with the key, then the first one
is returned. Use entry
to get all values associated with a given
key. Returns None
if there are no values associated with the key.
Returns true if the map contains a value for the specified key.
An iterator visiting all key-value pairs.
The iteration order is arbitrary, but consistent across platforms for the same crate version. Each key will be yielded once per associated value. So, if a key has 3 associated values, it will be yielded 3 times.
An iterator visiting all keys.
The iteration order is arbitrary, but consistent across platforms for the same crate version. Each key will be yielded only once even if it has multiple associated values.
Inserts a key-value pair into the map.
If the map did not previously have this key present, then None
is
returned.
If the map did have this key present, the new value is associated with
the key and all previous values are removed. Note that only a single
one of the previous values is returned. If there are multiple values
that have been previously associated with the key, then the first one is
returned. See insert_mult
on OccupiedEntry
for an API that returns
all values.
The key is not updated, though; this matters for types that can be ==
without being identical.
Inserts a key-value pair into the map.
If the map did not previously have this key present, then false
is
returned.
If the map did have this key present, the new value is pushed to the end
of the list of values currently associated with the key. The key is not
updated, though; this matters for types that can be ==
without being
identical.
Trait Implementations
Convert http::HeaderMap to a HeaderMap
Performs the conversion.
type Item = (&'a HeaderName, &'a HeaderValue)
type Item = (&'a HeaderName, &'a HeaderValue)
The type of the elements being iterated over.
type IntoIter = Iter<'a>
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
Auto Trait Implementations
impl RefUnwindSafe for HeaderMap
impl UnwindSafe for HeaderMap
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more