Enum cookie_store::CookieDomain
source · pub enum CookieDomain {
HostOnly(String),
Suffix(String),
NotPresent,
Empty,
}
Expand description
The domain of a Cookie
Variants§
HostOnly(String)
No Domain attribute in Set-Cookie header
Suffix(String)
Domain attribute from Set-Cookie header
NotPresent
Domain attribute was not present in the Set-Cookie header
Empty
Domain attribute-value was empty; technically undefined behavior, but suggested that this be treated as invalid
Implementations§
source§impl CookieDomain
impl CookieDomain
The concept of a domain match per IETF RFC6265 Section 5.1.3
sourcepub fn host_only(request_url: &Url) -> Result<CookieDomain, CookieError>
pub fn host_only(request_url: &Url) -> Result<CookieDomain, CookieError>
Get the CookieDomain::HostOnly variant based on request_url
. This is the effective behavior of
setting the domain-attribute to empty
sourcepub fn matches(&self, request_url: &Url) -> bool
pub fn matches(&self, request_url: &Url) -> bool
Tests if the given url::Url
meets the domain-match criteria
sourcepub fn host_is_identical(&self, request_url: &Url) -> bool
pub fn host_is_identical(&self, request_url: &Url) -> bool
Tests if the given url::Url
has a request-host identical to the domain attribute
sourcepub fn is_public_suffix(&self, psl: &List) -> bool
pub fn is_public_suffix(&self, psl: &List) -> bool
Tests if the domain-attribute is a public suffix as indicated by the provided
publicsuffix::List
.
Trait Implementations§
source§impl Clone for CookieDomain
impl Clone for CookieDomain
source§fn clone(&self) -> CookieDomain
fn clone(&self) -> CookieDomain
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CookieDomain
impl Debug for CookieDomain
source§impl<'de> Deserialize<'de> for CookieDomain
impl<'de> Deserialize<'de> for CookieDomain
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<'a> From<&'a CookieDomain> for String
impl<'a> From<&'a CookieDomain> for String
source§fn from(c: &'a CookieDomain) -> String
fn from(c: &'a CookieDomain) -> String
source§impl Hash for CookieDomain
impl Hash for CookieDomain
source§impl Ord for CookieDomain
impl Ord for CookieDomain
source§fn cmp(&self, other: &CookieDomain) -> Ordering
fn cmp(&self, other: &CookieDomain) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for CookieDomain
impl PartialEq for CookieDomain
source§fn eq(&self, other: &CookieDomain) -> bool
fn eq(&self, other: &CookieDomain) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for CookieDomain
impl PartialOrd for CookieDomain
source§fn partial_cmp(&self, other: &CookieDomain) -> Option<Ordering>
fn partial_cmp(&self, other: &CookieDomain) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for CookieDomain
impl Serialize for CookieDomain
source§impl<'a, 'c> TryFrom<&'a Cookie<'c>> for CookieDomain
impl<'a, 'c> TryFrom<&'a Cookie<'c>> for CookieDomain
Construct a CookieDomain::Suffix
from a cookie::Cookie
, which handles stripping a leading
‘.’ for us. If the cookie.domain is None or an empty string, the CookieDomain::Empty
variant
is returned.
NOTE: cookie::Cookie
domain values already have the leading ‘.’ stripped. To avoid
performing this step twice, the From<&cookie::Cookie>
impl should be used,
instead of passing cookie.domain
to the From<&str>
impl.
source§impl<'a> TryFrom<&'a str> for CookieDomain
impl<'a> TryFrom<&'a str> for CookieDomain
Construct a CookieDomain::Suffix
from a string, stripping a single leading ‘.’ if present.
If the source string is empty, returns the CookieDomain::Empty
variant.