pub struct Cookie(/* private fields */);Expand description
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=31d4d96e407aad42SID=31d4d96e407aad42; lang=en-US
Implementations§
Source§impl Cookie
impl Cookie
Sourcepub fn get(&self, name: &str) -> Option<&str>
pub fn get(&self, name: &str) -> Option<&str>
Lookup a value for a cookie name.
§Example
use rama_http_headers::{HeaderMapExt, Cookie};
use rama_http_types::{HeaderMap, 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);Trait Implementations§
Source§impl Header for Cookie
impl Header for Cookie
Source§fn name() -> &'static HeaderName
fn name() -> &'static HeaderName
The name of this header.
Source§fn decode<'i, I>(values: &mut I) -> Result<Self, Error>where
I: Iterator<Item = &'i HeaderValue>,
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>where
I: Iterator<Item = &'i HeaderValue>,
Decode this type from an iterator of
HeaderValues.Source§fn encode<E: Extend<HeaderValue>>(&self, values: &mut E)
fn encode<E: Extend<HeaderValue>>(&self, values: &mut E)
Encode this type to a
HeaderValue, and add it to a container
which has HeaderValue type as each element. Read moreSource§fn encode_to_value(&self) -> HeaderValue
fn encode_to_value(&self) -> HeaderValue
Encode this
Header to HeaderValue.Auto Trait Implementations§
impl !Freeze for Cookie
impl RefUnwindSafe for Cookie
impl Send for Cookie
impl Sync for Cookie
impl Unpin for Cookie
impl UnwindSafe for Cookie
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more