pub struct Headers { /* private fields */ }Expand description
Header fields, looked up without regard to case and written in the order they were set.
Implementations§
Source§impl Headers
impl Headers
Sourcepub fn from_pairs<I, N, V>(pairs: I) -> Self
pub fn from_pairs<I, N, V>(pairs: I) -> Self
Build a map from pairs, later pairs replacing earlier ones.
§Examples
use lino_rest_api::headers::Headers;
let headers = Headers::from_pairs([("Content-Type", "text/lino")]);
assert_eq!(headers.get("content-type"), Some("text/lino"));Sourcepub fn insert<N: Into<String>, V: Into<String>>(&mut self, name: N, value: V)
pub fn insert<N: Into<String>, V: Into<String>>(&mut self, name: N, value: V)
Set a field, replacing any existing one and keeping its position.
Sourcepub fn insert_missing<N: Into<String>, V: Into<String>>(
&mut self,
name: N,
value: V,
)
pub fn insert_missing<N: Into<String>, V: Into<String>>( &mut self, name: N, value: V, )
Set a field only when it is absent, which is how defaults are applied.
Sourcepub fn remove(&mut self, name: &str) -> Option<String>
pub fn remove(&mut self, name: &str) -> Option<String>
Remove a field, returning its value when there was one.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
The fields, in the order they were set.
Sourcepub fn extend_missing(&mut self, other: &Headers)
pub fn extend_missing(&mut self, other: &Headers)
Merge fields from another map, without overwriting what is already set.
Trait Implementations§
impl Eq for Headers
Source§impl<'a> IntoIterator for &'a Headers
impl<'a> IntoIterator for &'a Headers
impl StructuralPartialEq for 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 UnsafeUnpin 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.