pub struct CookieStore { /* private fields */ }Expand description
Implementations§
Source§impl CookieStore
impl CookieStore
👎Deprecated since 0.14.1: Please use the get_request_values function instead
get_request_values function insteadReturn an Iterator of the cookies for url in the store, suitable for submitting in an
HTTP request. As the items are intended for use in creating a Cookie header in a GET request,
they may contain only the name and value of a received cookie, eliding other parameters
such as path or expires. For iteration over Cookie instances containing all data, please
refer to CookieStore::matches.
Sourcepub fn get_request_values(
&self,
url: &Url,
) -> impl Iterator<Item = (&str, &str)>
pub fn get_request_values( &self, url: &Url, ) -> impl Iterator<Item = (&str, &str)>
Return an Iterator of the cookie (name, value) pairs for url in the store, suitable
for use in the Cookie header of an HTTP request. For iteration over Cookie instances,
please refer to CookieStore::matches.
Store the cookies received from url
Sourcepub fn with_suffix_list(self, psl: List) -> CookieStore
pub fn with_suffix_list(self, psl: List) -> CookieStore
Specify a publicsuffix::List for the CookieStore to allow public suffix
matching
Sourcepub fn contains(&self, domain: &str, path: &str, name: &str) -> bool
pub fn contains(&self, domain: &str, path: &str, name: &str) -> bool
Returns true if the CookieStore contains an unexpired Cookie corresponding to the
specified domain, path, and name.
Sourcepub fn contains_any(&self, domain: &str, path: &str, name: &str) -> bool
pub fn contains_any(&self, domain: &str, path: &str, name: &str) -> bool
Returns true if the CookieStore contains any (even an expired) Cookie corresponding
to the specified domain, path, and name.
Sourcepub fn get(&self, domain: &str, path: &str, name: &str) -> Option<&Cookie<'_>>
pub fn get(&self, domain: &str, path: &str, name: &str) -> Option<&Cookie<'_>>
Returns a reference to the unexpired Cookie corresponding to the specified domain,
path, and name.
Sourcepub fn get_any(
&self,
domain: &str,
path: &str,
name: &str,
) -> Option<&Cookie<'static>>
pub fn get_any( &self, domain: &str, path: &str, name: &str, ) -> Option<&Cookie<'static>>
Returns a reference to the (possibly expired) Cookie corresponding to the specified
domain, path, and name.
Sourcepub fn remove(
&mut self,
domain: &str,
path: &str,
name: &str,
) -> Option<Cookie<'static>>
pub fn remove( &mut self, domain: &str, path: &str, name: &str, ) -> Option<Cookie<'static>>
Removes a Cookie from the store, returning the Cookie if it was in the store
Sourcepub fn matches(&self, request_url: &Url) -> Vec<&Cookie<'static>>
pub fn matches(&self, request_url: &Url) -> Vec<&Cookie<'static>>
Returns a collection of references to unexpired cookies that path- and domain-match
request_url, as well as having HttpOnly and Secure attributes compatible with the
request_url.
Sourcepub fn parse(
&mut self,
cookie_str: &str,
request_url: &Url,
) -> Result<StoreAction, CookieError>
pub fn parse( &mut self, cookie_str: &str, request_url: &Url, ) -> Result<StoreAction, CookieError>
Parses a new Cookie from cookie_str and inserts it into the store.
Sourcepub fn insert_raw(
&mut self,
cookie: &RawCookie<'_>,
request_url: &Url,
) -> Result<StoreAction, CookieError>
pub fn insert_raw( &mut self, cookie: &RawCookie<'_>, request_url: &Url, ) -> Result<StoreAction, CookieError>
Converts a cookie::Cookie (from the cookie crate) into a cookie_store::Cookie and
inserts it into the store.
Sourcepub fn insert(
&mut self,
cookie: Cookie<'static>,
request_url: &Url,
) -> Result<StoreAction, CookieError>
pub fn insert( &mut self, cookie: Cookie<'static>, request_url: &Url, ) -> Result<StoreAction, CookieError>
Inserts cookie, received from request_url, into the store, following the rules of the
IETF RFC6265 Storage Model. If the
Cookie is unexpired and is successfully inserted, returns
Ok(StoreAction::Inserted). If the Cookie is expired and matches an existing
Cookie in the store, the existing Cookie wil be expired() and
Ok(StoreAction::ExpiredExisting) will be returned.
Sourcepub fn iter_unexpired<'a>(
&'a self,
) -> impl Iterator<Item = &'a Cookie<'static>> + 'a
pub fn iter_unexpired<'a>( &'a self, ) -> impl Iterator<Item = &'a Cookie<'static>> + 'a
An iterator visiting all the unexpired cookies in the store
Sourcepub fn iter_any<'a>(&'a self) -> impl Iterator<Item = &'a Cookie<'static>> + 'a
pub fn iter_any<'a>(&'a self) -> impl Iterator<Item = &'a Cookie<'static>> + 'a
An iterator visiting all (including expired) cookies in the store
Sourcepub fn save<W, E, F>(
&self,
writer: &mut W,
cookie_to_string: F,
) -> Result<(), Error>
pub fn save<W, E, F>( &self, writer: &mut W, cookie_to_string: F, ) -> Result<(), Error>
Serialize any unexpired and persistent cookies in the store with cookie_to_string
and write them to writer
Sourcepub fn save_incl_expired_and_nonpersistent<W, E, F>(
&self,
writer: &mut W,
cookie_to_string: F,
) -> Result<(), Error>
pub fn save_incl_expired_and_nonpersistent<W, E, F>( &self, writer: &mut W, cookie_to_string: F, ) -> Result<(), Error>
Serialize all (including expired and non-persistent) cookies in the store with cookie_to_string and write them to writer
Sourcepub fn load<R, E, F>(
reader: R,
cookie_from_str: F,
) -> Result<CookieStore, Error>
pub fn load<R, E, F>( reader: R, cookie_from_str: F, ) -> Result<CookieStore, Error>
Load cookies from reader, deserializing with cookie_from_str, skipping any expired
cookies
Sourcepub fn load_all<R, E, F>(
reader: R,
cookie_from_str: F,
) -> Result<CookieStore, Error>
pub fn load_all<R, E, F>( reader: R, cookie_from_str: F, ) -> Result<CookieStore, Error>
Load cookies from reader, deserializing with cookie_from_str, loading both unexpired
and expired cookies
Create a CookieStore from an iterator of Cookie values. When
include_expired is true, both expired and unexpired cookies in the incoming
iterator will be included in the produced CookieStore; otherwise, only
unexpired cookies will be included, and expired cookies filtered
out.
pub fn new(public_suffix_list: Option<List>) -> Self
Source§impl CookieStore
Legacy serialization implementations. These methods do not produce/consume valid JSON output compatible with
typical JSON libraries/tools.
impl CookieStore
Legacy serialization implementations. These methods do not produce/consume valid JSON output compatible with typical JSON libraries/tools.
Sourcepub fn save_json<W: Write>(&self, writer: &mut W) -> Result<(), Error>
👎Deprecated since 0.22.0: See cookie_store::serde modules for more robust de/serialization options
pub fn save_json<W: Write>(&self, writer: &mut W) -> Result<(), Error>
cookie_store::serde modules for more robust de/serialization optionsSerialize any unexpired and persistent cookies in the store to JSON format and
write them to writer
NB: this method does not produce valid JSON which can be directly loaded; such output must be loaded via the corresponding method CookieStore::load_json. For a more robust/universal JSON format, see crate::serde::json, which produces output incompatible with this method.
Sourcepub fn save_incl_expired_and_nonpersistent_json<W: Write>(
&self,
writer: &mut W,
) -> Result<(), Error>
👎Deprecated since 0.22.0: See cookie_store::serde modules for more robust de/serialization options
pub fn save_incl_expired_and_nonpersistent_json<W: Write>( &self, writer: &mut W, ) -> Result<(), Error>
cookie_store::serde modules for more robust de/serialization optionsSerialize all (including expired and non-persistent) cookies in the store to JSON format and write them to writer
NB: this method does not produce valid JSON which can be directly loaded; such output must be loaded via the corresponding method CookieStore::load_json. For a more robust/universal JSON format, see crate::serde::json, which produces output incompatible with this method.
Sourcepub fn load_json<R: BufRead>(reader: R) -> Result<CookieStore, Error>
👎Deprecated since 0.22.0: See cookie_store::serde modules for more robust de/serialization options
pub fn load_json<R: BufRead>(reader: R) -> Result<CookieStore, Error>
cookie_store::serde modules for more robust de/serialization optionsLoad JSON-formatted cookies from reader, skipping any expired cookies
NB: this method does not expect true valid JSON; it is designed to load output from the corresponding method CookieStore::save_json. For a more robust/universal JSON format, see crate::serde::json, which produces output incompatible with this method.
Sourcepub fn load_json_all<R: BufRead>(reader: R) -> Result<CookieStore, Error>
👎Deprecated since 0.22.0: See cookie_store::serde modules for more robust de/serialization options
pub fn load_json_all<R: BufRead>(reader: R) -> Result<CookieStore, Error>
cookie_store::serde modules for more robust de/serialization optionsLoad JSON-formatted cookies from reader, loading both expired and unexpired cookies
NB: this method does not expect true valid JSON; it is designed to load output from the corresponding method CookieStore::save_json. For a more robust/universal JSON format, see crate::serde::json, which produces output incompatible with this method.
Trait Implementations§
Source§impl Clone for CookieStore
impl Clone for CookieStore
Source§fn clone(&self) -> CookieStore
fn clone(&self) -> CookieStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more