[][src]Struct headers::Cookie

pub struct Cookie(_);

Cookie header, defined in RFC6265

If the user agent does attach a Cookie header field to an HTTP request, the user agent must send the cookie-string as the value of the header field.

When the user agent generates an HTTP request, the user agent MUST NOT attach more than one Cookie header field.

Example values

  • SID=31d4d96e407aad42
  • SID=31d4d96e407aad42; lang=en-US

Methods

impl Cookie[src]

pub fn get(&self, name: &str) -> Option<&str>[src]

Lookup a value for a cookie name.

Example

use headers::{Cookie, HeaderMap, HeaderMapExt, HeaderValue};

// Setup the header map with strings...
let mut headers = HeaderMap::new();
headers.insert("cookie", HeaderValue::from_static("lang=en-US"));

// Parse a `Cookie` so we can play with it...
let cookie = headers
    .typed_get::<Cookie>()
    .expect("we just inserted a valid Cookie");

assert_eq!(cookie.get("lang"), Some("en-US"));
assert_eq!(cookie.get("SID"), None);

pub fn len(&self) -> usize[src]

Get the number of key-value pairs this Cookie contains.

pub fn iter(
    &self
) -> impl Iterator<Item = (&str, &str)>
[src]

Iterator the key-value pairs of this Cookie header.

Trait Implementations

impl Clone for Cookie[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Cookie[src]

impl Header for Cookie[src]

Auto Trait Implementations

impl Send for Cookie

impl Sync for Cookie

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 = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

impl<T> Same for T

type Output = T

Should always be Self