[][src]Struct http_req::response::Headers

pub struct 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]

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_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]

type Err = ParseErr

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Send for Headers

impl Sync for Headers

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]