Struct hyper::header::Headers
[−]
[src]
pub struct Headers { /* fields omitted */ }
A map of header fields on requests and responses.
Methods
impl Headers
[src]
impl Headers
pub fn new() -> Headers
[src]
pub fn new() -> Headers
Creates a new, empty headers map.
pub fn with_capacity(len: usize) -> Headers
[src]
pub fn with_capacity(len: usize) -> Headers
Creates a new Headers
struct with space reserved for len
headers.
pub fn set<H: Header>(&mut self, value: H)
[src]
pub fn set<H: Header>(&mut self, value: H)
Set a header field to the corresponding value.
The field is determined by the type of the value being set.
pub fn get<H: Header>(&self) -> Option<&H>
[src]
pub fn get<H: Header>(&self) -> Option<&H>
Get a reference to the header field's value, if it exists.
pub fn get_mut<H: Header>(&mut self) -> Option<&mut H>
[src]
pub fn get_mut<H: Header>(&mut self) -> Option<&mut H>
Get a mutable reference to the header field's value, if it exists.
pub fn has<H: Header>(&self) -> bool
[src]
pub fn has<H: Header>(&self) -> bool
Returns a boolean of whether a certain header is in the map.
Example:
headers.set(ContentType::json()); assert!(headers.has::<ContentType>());
pub fn remove<H: Header>(&mut self) -> Option<H>
[src]
pub fn remove<H: Header>(&mut self) -> Option<H>
Removes a header from the map, if one existed. Returns the header, if one has been removed and could be parsed.
Note that this function may return None
even though a header was removed. If you want to
know whether a header exists, rather rely on has
.
ⓘImportant traits for HeadersItems<'a>pub fn iter(&self) -> HeadersItems
[src]
pub fn iter(&self) -> HeadersItems
Returns an iterator over the header fields.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of headers in the map.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Remove all headers from the map.
pub fn get_raw(&self, name: &str) -> Option<&Raw>
[src]
pub fn get_raw(&self, name: &str) -> Option<&Raw>
Access the raw value of a header.
Prefer to use the typed getters instead.
Example:
let raw = headers.get_raw("content-type").unwrap(); assert_eq!(raw, "text/plain");
pub fn set_raw<K: Into<Cow<'static, str>>, V: Into<Raw>>(
&mut self,
name: K,
value: V
)
[src]
pub fn set_raw<K: Into<Cow<'static, str>>, V: Into<Raw>>(
&mut self,
name: K,
value: V
)
Set the raw value of a header, bypassing any typed headers.
Example:
headers.set_raw("content-length", b"1".as_ref()); headers.set_raw("content-length", "2"); headers.set_raw("content-length", "3".to_string()); headers.set_raw("content-length", vec![vec![b'4']]);
pub fn append_raw<K: Into<Cow<'static, str>>, V: Into<Raw>>(
&mut self,
name: K,
value: V
)
[src]
pub fn append_raw<K: Into<Cow<'static, str>>, V: Into<Raw>>(
&mut self,
name: K,
value: V
)
Append a value to raw value of this header.
If a header already contains a value, this will add another line to it.
If a header does not exist for this name, a new one will be created with the value.
Example:
headers.append_raw("x-foo", b"bar".to_vec()); headers.append_raw("x-foo", b"quux".to_vec());
pub fn remove_raw(&mut self, name: &str)
[src]
pub fn remove_raw(&mut self, name: &str)
Remove a header by name.
Trait Implementations
impl Clone for Headers
[src]
impl Clone for Headers
fn clone(&self) -> Headers
[src]
fn clone(&self) -> Headers
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Default for Headers
[src]
impl Default for Headers
impl PartialEq for Headers
[src]
impl PartialEq for Headers
fn eq(&self, other: &Headers) -> bool
[src]
fn eq(&self, other: &Headers) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Display for Headers
[src]
impl Display for Headers
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Debug for Headers
[src]
impl Debug for Headers
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a> Extend<HeaderView<'a>> for Headers
[src]
impl<'a> Extend<HeaderView<'a>> for Headers
fn extend<I: IntoIterator<Item = HeaderView<'a>>>(&mut self, iter: I)
[src]
fn extend<I: IntoIterator<Item = HeaderView<'a>>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
impl<'a> Extend<(&'a str, Bytes)> for Headers
[src]
impl<'a> Extend<(&'a str, Bytes)> for Headers
fn extend<I: IntoIterator<Item = (&'a str, Bytes)>>(&mut self, iter: I)
[src]
fn extend<I: IntoIterator<Item = (&'a str, Bytes)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
impl<'a> FromIterator<HeaderView<'a>> for Headers
[src]
impl<'a> FromIterator<HeaderView<'a>> for Headers
fn from_iter<I: IntoIterator<Item = HeaderView<'a>>>(iter: I) -> Headers
[src]
fn from_iter<I: IntoIterator<Item = HeaderView<'a>>>(iter: I) -> Headers
Creates a value from an iterator. Read more