pub struct HeaderFields { /* private fields */ }Expand description
Collection of header fields.
The collection uses Vec<_> internally to store the header fields, so it
preserves the field order and allows multiple fields with the same name.
This also means that complexity of some operations is O(n). However, this
should not pose a problem in practice, as the number of header fields is
usually quite small. The number of header fields can be also limited by the
header field decoder. It is a trade-off between performance and footprint.
Implementations§
Source§impl HeaderFields
impl HeaderFields
Sourcepub const fn new() -> HeaderFields
pub const fn new() -> HeaderFields
Create a new collection of header fields.
Sourcepub fn with_capacity(capacity: usize) -> HeaderFields
pub fn with_capacity(capacity: usize) -> HeaderFields
Create a new collection of header fields with a given initial capacity.
Sourcepub fn add<T>(&mut self, field: T)where
T: Into<HeaderField>,
pub fn add<T>(&mut self, field: T)where
T: Into<HeaderField>,
Add a given header field to the collection.
This is an O(1) operation.
Sourcepub fn set<T>(&mut self, field: T)where
T: Into<HeaderField>,
pub fn set<T>(&mut self, field: T)where
T: Into<HeaderField>,
Replace all header fields having the same name (if any).
This is an O(n) operation.
Sourcepub fn remove<N>(&mut self, name: &N)
pub fn remove<N>(&mut self, name: &N)
Remove all header fields with a given name.
This is an O(n) operation.
Sourcepub fn get<'a, N>(&'a self, name: &'a N) -> FieldIter<'a> ⓘ
pub fn get<'a, N>(&'a self, name: &'a N) -> FieldIter<'a> ⓘ
Get header fields with a given name.
This is an O(n) operation.
Sourcepub fn last<'a, N>(&'a self, name: &'a N) -> Option<&'a HeaderField>
pub fn last<'a, N>(&'a self, name: &'a N) -> Option<&'a HeaderField>
Get the last header field with a given name.
This is an O(n) operation.
Sourcepub fn last_value<'a, N>(&'a self, name: &'a N) -> Option<&'a HeaderFieldValue>
pub fn last_value<'a, N>(&'a self, name: &'a N) -> Option<&'a HeaderFieldValue>
Get value of the last header field with a given name.
This is an O(n) operation.
Trait Implementations§
Source§impl Clone for HeaderFields
impl Clone for HeaderFields
Source§fn clone(&self) -> HeaderFields
fn clone(&self) -> HeaderFields
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more