[−][src]Struct actix_web::http::header::HeaderMap
A set of HTTP headers
HeaderMap
is an multimap of HeaderName
to values.
Methods
impl HeaderMap
[src]
pub fn new() -> HeaderMap
[src]
Create an empty HeaderMap
.
The map will be created without any capacity. This function will not allocate.
pub fn with_capacity(capacity: usize) -> HeaderMap
[src]
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.
pub fn len(&self) -> usize
[src]
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.
pub fn is_empty(&self) -> bool
[src]
Returns true if the map contains no elements.
pub fn clear(&mut self)
[src]
Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.
pub fn capacity(&self) -> usize
[src]
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.
pub fn reserve(&mut self, additional: usize)
[src]
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.
pub fn get<N>(&self, name: N) -> Option<&HeaderValue> where
N: AsName,
[src]
N: AsName,
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.
ⓘImportant traits for GetAll<'a>pub fn get_all<N>(&self, name: N) -> GetAll where
N: AsName,
[src]
N: AsName,
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.
pub fn get_mut<N>(&mut self, name: N) -> Option<&mut HeaderValue> where
N: AsName,
[src]
N: AsName,
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.
pub fn contains_key<N>(&self, key: N) -> bool where
N: AsName,
[src]
N: AsName,
Returns true if the map contains a value for the specified key.
pub fn iter(&self) -> Iter
[src]
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.
pub fn keys(&self) -> Keys
[src]
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.
pub fn insert(&mut self, key: HeaderName, val: HeaderValue)
[src]
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.
pub fn append(&mut self, key: HeaderName, value: HeaderValue)
[src]
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.
pub fn remove<N>(&mut self, key: N) where
N: AsName,
[src]
N: AsName,
Removes all headers for a particular header name from the map.
Trait Implementations
impl Clone for HeaderMap
[src]
fn clone(&self) -> HeaderMap
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> IntoIterator for &'a HeaderMap
[src]
type Item = (&'a HeaderName, &'a HeaderValue)
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> <&'a HeaderMap as IntoIterator>::IntoIter
[src]
impl Debug for HeaderMap
[src]
impl From<HeaderMap<HeaderValue>> for HeaderMap
[src]
Convert http::HeaderMap to a HeaderMap
fn from(map: HeaderMap<HeaderValue>) -> HeaderMap
[src]
Auto Trait Implementations
impl Send for HeaderMap
impl Unpin for HeaderMap
impl Sync for HeaderMap
impl UnwindSafe for HeaderMap
impl RefUnwindSafe for HeaderMap
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,