Struct websocket::header::Headers [−][src]
A map of header fields on requests and responses.
Implementations
impl Headers
[src][−]
pub fn new() -> Headers
[src][−]
Creates a new, empty headers map.
pub fn set<H>(&mut self, value: H) where
H: Header + HeaderFormat,
[src][−]
H: Header + HeaderFormat,
Set a header field to the corresponding value.
The field is determined by the type of the value being set.
pub fn get_raw(&self, name: &str) -> Option<&[Vec<u8, Global>]>
[src][−]
Access the raw value of a header.
Prefer to use the typed getters instead.
Example:
let raw_content_type = headers.get_raw("content-type");
pub fn set_raw<K>(&mut self, name: K, value: Vec<Vec<u8, Global>, Global>) where
K: Into<Cow<'static, str>>,
[src][−]
K: Into<Cow<'static, str>>,
Set the raw value of a header, bypassing any typed headers.
Note: This will completely replace any current value for this header name.
Example:
headers.set_raw("content-length", vec![b"5".to_vec()]);
pub fn append_raw<K>(&mut self, name: K, value: Vec<u8, Global>) where
K: Into<Cow<'static, str>>,
[src][−]
K: Into<Cow<'static, str>>,
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 doesnot 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][−]
Remove a header set by set_raw
pub fn get<H>(&self) -> Option<&H> where
H: Header + HeaderFormat,
[src][−]
H: Header + HeaderFormat,
Get a reference to the header field’s value, if it exists.
pub fn get_mut<H>(&mut self) -> Option<&mut H> where
H: Header + HeaderFormat,
[src][−]
H: Header + HeaderFormat,
Get a mutable reference to the header field’s value, if it exists.
pub fn has<H>(&self) -> bool where
H: Header + HeaderFormat,
[src][−]
H: Header + HeaderFormat,
Returns a boolean of whether a certain header is in the map.
Example:
let has_type = headers.has::<ContentType>();
pub fn remove<H>(&mut self) -> bool where
H: Header + HeaderFormat,
[src][−]
H: Header + HeaderFormat,
Removes a header from the map, if one existed. Returns true if a header has been removed.
pub fn iter(&self) -> HeadersItems<'_>ⓘNotable traits for HeadersItems<'a>
impl<'a> Iterator for HeadersItems<'a> type Item = HeaderView<'a>;
[src][−]
Notable traits for HeadersItems<'a>
impl<'a> Iterator for HeadersItems<'a> type Item = HeaderView<'a>;
Returns an iterator over the header fields.
pub fn len(&self) -> usize
[src][−]
Returns the number of headers in the map.
pub fn clear(&mut self)
[src][−]
Remove all headers from the map.
Trait Implementations
impl Clone for Headers
[src][+]
impl Debug for Headers
[src][+]
impl Display for Headers
[src][+]
impl<'a> Extend<HeaderView<'a>> for Headers
[src][+]
impl<'a> FromIterator<HeaderView<'a>> for Headers
[src][+]
impl PartialEq<Headers> for Headers
[src][+]
Auto Trait Implementations
impl !RefUnwindSafe for Headers
impl Send for Headers
impl !Sync for Headers
impl Unpin for Headers
impl !UnwindSafe for Headers
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src][+]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<T> Typeable for T where
T: Any,
[+]
T: Any,