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

Implementations

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]

impl Debug for Cookie[src]

impl Header for Cookie[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.