pub struct Headers { /* private fields */ }
Expand description
A map of header fields on requests and responses.
Implementations§
Source§impl Headers
impl Headers
Sourcepub fn set<H>(&mut self, value: H)where
H: Header + HeaderFormat,
pub fn set<H>(&mut self, value: H)where
H: Header + HeaderFormat,
Set a header field to the corresponding value.
The field is determined by the type of the value being set.
Sourcepub fn get_raw(&self, name: &str) -> Option<&[Vec<u8>]>
pub fn get_raw(&self, name: &str) -> Option<&[Vec<u8>]>
Access the raw value of a header.
Prefer to use the typed getters instead.
Example:
let raw_content_type = headers.get_raw("content-type");
Sourcepub fn set_raw<K>(&mut self, name: K, value: Vec<Vec<u8>>)
pub fn set_raw<K>(&mut self, name: K, value: Vec<Vec<u8>>)
Set the raw value of a header, bypassing any typed headers.
Example:
headers.set_raw("content-length", vec![b"5".to_vec()]);
Sourcepub fn remove_raw(&mut self, name: &str)
pub fn remove_raw(&mut self, name: &str)
Remove a header set by set_raw
Sourcepub fn get<H>(&self) -> Option<&H>where
H: Header + HeaderFormat,
pub fn get<H>(&self) -> Option<&H>where
H: Header + HeaderFormat,
Get a reference to the header field’s value, if it exists.
Sourcepub fn get_mut<H>(&mut self) -> Option<&mut H>where
H: Header + HeaderFormat,
pub fn get_mut<H>(&mut self) -> Option<&mut H>where
H: Header + HeaderFormat,
Get a mutable reference to the header field’s value, if it exists.
Sourcepub fn has<H>(&self) -> boolwhere
H: Header + HeaderFormat,
pub fn has<H>(&self) -> boolwhere
H: Header + HeaderFormat,
Returns a boolean of whether a certain header is in the map.
Example:
let has_type = headers.has::<ContentType>();
Sourcepub fn remove<H>(&mut self) -> boolwhere
H: Header + HeaderFormat,
pub fn remove<H>(&mut self) -> boolwhere
H: Header + HeaderFormat,
Removes a header from the map, if one existed. Returns true if a header has been removed.
Sourcepub fn iter(&self) -> HeadersItems<'_> ⓘ
pub fn iter(&self) -> HeadersItems<'_> ⓘ
Returns an iterator over the header fields.
Trait Implementations§
Source§impl<'a> Extend<HeaderView<'a>> for Headers
impl<'a> Extend<HeaderView<'a>> for Headers
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = HeaderView<'a>>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = HeaderView<'a>>,
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<'a> FromIterator<HeaderView<'a>> for Headers
impl<'a> FromIterator<HeaderView<'a>> for Headers
Source§fn from_iter<I>(iter: I) -> Headerswhere
I: IntoIterator<Item = HeaderView<'a>>,
fn from_iter<I>(iter: I) -> Headerswhere
I: IntoIterator<Item = HeaderView<'a>>,
Creates a value from an iterator. Read more
Auto Trait Implementations§
impl Freeze for Headers
impl !RefUnwindSafe for Headers
impl Send for Headers
impl !Sync for Headers
impl Unpin for Headers
impl !UnwindSafe for Headers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> PersistentInto<Arc<Mutex<T>>> for T
impl<T> PersistentInto<Arc<Mutex<T>>> for T
Source§fn persistent_into(self) -> Arc<Mutex<T>>
fn persistent_into(self) -> Arc<Mutex<T>>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<Arc<RwLock<T>>> for T
impl<T> PersistentInto<Arc<RwLock<T>>> for T
Source§fn persistent_into(self) -> Arc<RwLock<T>>
fn persistent_into(self) -> Arc<RwLock<T>>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<Arc<T>> for T
impl<T> PersistentInto<Arc<T>> for T
Source§fn persistent_into(self) -> Arc<T>
fn persistent_into(self) -> Arc<T>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<T> for T
impl<T> PersistentInto<T> for T
Source§fn persistent_into(self) -> T
fn persistent_into(self) -> T
Convert
self
into a value of type T
.