pub struct Headers { /* private fields */ }
Expand description
An immutable view of headers
Implementations§
Source§impl Headers
impl Headers
Sourcepub fn get(&self, key: impl AsRef<str>) -> Option<&str>
pub fn get(&self, key: impl AsRef<str>) -> Option<&str>
Returns the value for a given key
If multiple values are associated, the first value is returned See HeaderMap::get
Sourcepub fn get_all(&self, key: impl AsRef<str>) -> impl Iterator<Item = &str>
pub fn get_all(&self, key: impl AsRef<str>) -> impl Iterator<Item = &str>
Returns all values for a given key
Sourcepub fn iter(&self) -> HeadersIter<'_> ⓘ
pub fn iter(&self) -> HeadersIter<'_> ⓘ
Returns an iterator over the headers
Sourcepub fn contains_key(&self, key: impl AsRef<str>) -> bool
pub fn contains_key(&self, key: impl AsRef<str>) -> bool
Returns true if this header is present
Sourcepub fn insert(
&mut self,
key: impl AsHeaderComponent,
value: impl AsHeaderComponent,
) -> Option<String>
pub fn insert( &mut self, key: impl AsHeaderComponent, value: impl AsHeaderComponent, ) -> Option<String>
Insert a value into the headers structure.
This will replace any existing value for this key. Returns the previous associated value if any.
§Panics
If the key is not valid ASCII, or if the value is not valid UTF-8, this function will panic.
Sourcepub fn try_insert(
&mut self,
key: impl AsHeaderComponent,
value: impl AsHeaderComponent,
) -> Result<Option<String>, HttpError>
pub fn try_insert( &mut self, key: impl AsHeaderComponent, value: impl AsHeaderComponent, ) -> Result<Option<String>, HttpError>
Insert a value into the headers structure.
This will replace any existing value for this key. Returns the previous associated value if any.
If the key is not valid ASCII, or if the value is not valid UTF-8, this function will return an error.
Sourcepub fn append(
&mut self,
key: impl AsHeaderComponent,
value: impl AsHeaderComponent,
) -> bool
pub fn append( &mut self, key: impl AsHeaderComponent, value: impl AsHeaderComponent, ) -> bool
Appends a value to a given key
§Panics
If the key is not valid ASCII, or if the value is not valid UTF-8, this function will panic.
Sourcepub fn try_append(
&mut self,
key: impl AsHeaderComponent,
value: impl AsHeaderComponent,
) -> Result<bool, HttpError>
pub fn try_append( &mut self, key: impl AsHeaderComponent, value: impl AsHeaderComponent, ) -> Result<bool, HttpError>
Appends a value to a given key
If the key is not valid ASCII, or if the value is not valid UTF-8, this function will return an error.
Trait Implementations§
Source§impl<'a> IntoIterator for &'a Headers
impl<'a> IntoIterator for &'a Headers
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more