pub struct Headers<'a> { /* private fields */ }
Expand description
A collection of Headers
Implementations§
Source§impl<'a> Headers<'a>
impl<'a> Headers<'a>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Headers-Instance, for performance reasons
it is recommended to use the with_capacity
method
as that would avoid frequent reallocations
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Creates the Headers-Object with the given Capacity prereserved for future Headers. This should be used when you already kind of know how many Headers this will hold, as it will avoid extra allocations in the future
Sourcepub fn set<'b, K, V>(&mut self, key: K, value: V)
pub fn set<'b, K, V>(&mut self, key: K, value: V)
Sets the Value of the of the Header for the given Key to the given Value
§Behaviour
Checks if the Key is already present in the Collection and removes it if that is the case. Then adds the new Header to the End of the Collection
Sourcepub fn append<K, V>(&mut self, key: K, value: V)
pub fn append<K, V>(&mut self, key: K, value: V)
Appends the given Key-Value Pair to the end of the Collection, without checking if the Key is already present in the Collection
Sourcepub fn remove<K>(&mut self, key: K)
pub fn remove<K>(&mut self, key: K)
Removes the first Header, that matches the given Key, from the Collection
Sourcepub fn get<K>(&self, key: K) -> Option<&HeaderValue<'a>>
pub fn get<K>(&self, key: K) -> Option<&HeaderValue<'a>>
Searches the Collection for a Header that matches the given Key
Returns:
- None: if no Header matches the Key
- A Reference to the underlying Header-Value that belongs to the Key
Sourcepub fn serialize(&self, buf: &mut Vec<u8>)
pub fn serialize(&self, buf: &mut Vec<u8>)
Serializes the Collection of Headers into the given Buffer by append to it
Sourcepub fn get_max_value_size(&self) -> usize
pub fn get_max_value_size(&self) -> usize
Returns the Size in bytes of the biggest Value as text.
This means that all the Header-Values in this collection can fit in a buffer of this size.
Sourcepub fn get_header_count(&self) -> usize
pub fn get_header_count(&self) -> usize
Returns the Number of Headers in this collection