[−][src]Struct http_req::response::Headers
Wrapper around HashMap<String, String> with additional functionality for parsing HTTP headers
Example
use http_req::response::Headers; let mut headers = Headers::new(); headers.insert("Connection", "Close"); assert_eq!(headers.get("Connection"), Some(&"Close".to_string()))
Methods
impl Headers
[src]
pub fn new() -> Headers
[src]
Creates an empty Headers
.
The headers are initially created with a capacity of 0, so they will not allocate until it is first inserted into.
pub fn with_capacity(capacity: usize) -> Headers
[src]
Creates empty Headers
with the specified capacity.
The headers will be able to hold at least capacity elements without reallocating. If capacity is 0, the headers will not allocate.
pub fn iter(&self) -> Iter<String, String>
[src]
An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&String, &String).
pub fn get<T: ToString>(&self, k: T) -> Option<&String>
[src]
Returns a reference to the value corresponding to the key.
pub fn insert<T: ?Sized, U: ?Sized>(
&mut self,
key: &T,
val: &U
) -> Option<String> where
T: ToString,
U: ToString,
[src]
&mut self,
key: &T,
val: &U
) -> Option<String> where
T: ToString,
U: ToString,
Inserts a key-value pair into the headers.
If the headers did not have this key present, None is returned.
If the headers did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical.
pub fn default_http(uri: &Uri) -> Headers
[src]
Creates default headers for a HTTP request
Trait Implementations
impl PartialEq<Headers> for Headers
[src]
impl Default for Headers
[src]
impl From<HashMap<String, String, RandomState>> for Headers
[src]
impl From<Headers> for HashMap<String, String>
[src]
impl Clone for Headers
[src]
fn clone(&self) -> Headers
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Headers
[src]
impl FromStr for Headers
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,