Skip to main content

CookieMap

Struct CookieMap 

Source
pub struct CookieMap(pub HashMap<String, Cookie>);

Tuple Fields§

§0: HashMap<String, Cookie>

Implementations§

Source§

impl CookieMap

Source

pub fn new() -> CookieMap

Source

pub fn parse<T>(cookies: T) -> CookieMap
where T: Into<String>,

Parses Cookie header into a Cookie Map

use crate::cookie::CookieMap;
let cookies = CookieMap::parse("session_id=114674271600181257; session_cont=owM2IdZ27G8SnQdjVWR37YocLRblDLcENy5JRomDKYLFHqcSt1J57C9QTbR4efccwaIZ7ZK1hNAo3osd5AvczzVMNcvjrXgtsoSPS1Fhn1vtIs6BWoOkBWaRYH76PysAOpXt1L2QeIIC8jdr/QnhhDULWaYekzR+Qk9znT+K4G3y9LjxT2P1rbVKc3yw+Zuvr3RyWLpwYxvRVLT5DwvytYNeiZ49gMHpx50VmRJiY+r8ZyIcQVRjcHblLCtt9O5qTh6oOA9yeWXsCdsRFmMbthbKmKlipMyhcN8TFzlgIx8J4QEtVyqg5dLE/Sfwzx+fj9wmgEuqiumNUg+B0D7ElCfyRBo1ovQr0yBaeli/97NzBZVzwYWZMlZt8hcHAkbxlfnPpOc3kXWoyy5fuaimJxIAPbXP4hkNN7HDDqi+mOxvkCxSX1DtosHd8nyclFdpPo/OfQDDlpYQxFAleEsLb+VVtYnTXP2U54hfNf7yHAaj1/1kYB+9ytIIZVWDeX5U83h6FcbxtPJcYXSqnD8iZjujcFiKHSdHMLuM9VQoTk7I3APtX6k1cgtFXHdxZsuy1Dq1UZqrtOAGcKki3kZWzFxbKB/bAX4M5p8xHgiCGwch7EcnOC6cuiulb65uGzDTf9H6VziSPkRecO5tbBSLbh9w1PBDs8ftQZUsxAXHzCVYP1/DhcWGqc9j7AW9Mm0nbQYQlW5kzfmmbttj9sFHsoVEX9dI7HJ+wT16cmkxGwAfbcfQ7MVpZDW2WOatr72JL5MRRfaYQc1H1hiL0TFX4YcZvBpcbNFG+iIUoytxw1ChnLrJkR7r+O9J2PRro2ipbyxZaJF8kEA1615Xm8PZ7YVQLdESJZERL1PHyWTALJqnXu4KBafsrng8aUkgP2z1wvPXk2lMz8cqVVDhZKW18XS7ugc0vMBplP0L6zvoUJcYcxMX5ZhLSzpTYSUBLM0zE4g5LCwZoNrZ36B2dXqItyRbE1u2X8qqvM4wGL6u6SH4oDJqiSLzdCr9r6bPKiGYVkdiyRQMOpnb0xT8xumebuQUxYsJqIErpjIQZDU09HZ5JJQZYuWmFa74+2M+9n7Fh/cmlJ0oV3p28Zg9Nz4EQd8YtepUSAjCEThkxOIx6A==");
assert_eq!(cookies.get("session_id").unwrap().value, "114674271600181257");
println!("{:?}", cookies.get("session_cont").unwrap().get_path()); // None
Source

pub fn parse_set_cookies<'a, I, T>(set_cookies: I) -> CookieMap
where I: IntoIterator<Item = T>, T: AsRef<str>,

Parses multiple Set-Cookie headers into a CookieMap.

§Arguments
  • set_cookies - A collection of Set-Cookie header values
§Returns

A CookieMap containing the parsed cookies.

§Examples
use crate::cookie::CookieMap;

let set_cookies = vec![
    "sessionId=abc123; Path=/; Secure",
    "theme=dark; Path=/settings"
];

let cookies = CookieMap::parse_set_cookies(&set_cookies);
assert_eq!(cookies.get("sessionId").unwrap().value, "abc123");
assert_eq!(cookies.get("theme").unwrap().value, "dark");
assert_eq!(cookies.get("theme").unwrap().get_path(), Some("/settings".to_string()));
Source

pub fn get<T>(&self, key: T) -> Option<&Cookie>
where T: AsRef<str>,

Source

pub fn set<T>(&mut self, key: T, value: Cookie)
where T: Into<String>,

Source

pub fn remove<T>(&mut self, key: T) -> Option<Cookie>
where T: AsRef<str>,

Source

pub fn clear(&mut self)

Source

pub fn response(&self) -> HeaderValue

Source

pub fn request(&self) -> String

Trait Implementations§

Source§

impl Clone for CookieMap

Source§

fn clone(&self) -> CookieMap

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CookieMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for CookieMap

Source§

fn default() -> CookieMap

Returns the “default value” for a type. Read more
Source§

impl From<HashMap<String, String>> for CookieMap

Source§

fn from(map: HashMap<String, String>) -> CookieMap

Converts to this type from the input type.
Source§

impl IntoIterator for CookieMap

Source§

type Item = (String, Cookie)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<String, Cookie>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <CookieMap as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for CookieMap

Source§

fn eq(&self, other: &CookieMap) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CookieMap

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ParamValue for T
where T: Any + Clone + Send + Sync + 'static,

Source§

fn clone_box(&self) -> Box<dyn ParamValue>

Clones this value and returns it as a boxed ParamValue. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the underlying value as Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns a mutable reference to the underlying value as Any. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more