pub struct Cookie { /* private fields */ }Implementations§
Source§impl Cookie
impl Cookie
Sourcepub fn new<N, V>(name: N, value: V) -> Cookie
pub fn new<N, V>(name: N, value: V) -> Cookie
Creates a new cookie with the given name and value.
Sourcepub fn named<N>(name: N) -> Cookie
pub fn named<N>(name: N) -> Cookie
Creates a new cookie with the given name and an empty value.
Sourcepub fn remove<N>(name: N) -> Cookie
pub fn remove<N>(name: N) -> Cookie
Creates a cookie that can be used to remove the cookie from the user-agent. This sets the Expires attribute in the past and MaxAge to 0 seconds.
To ensure a cookie is removed from the user-agent, set the Path and Domain attributes
with the same values that were used to create the cookie.
Sourcepub fn build<N, V>(name: N, value: V) -> CookieBuilder
pub fn build<N, V>(name: N, value: V) -> CookieBuilder
Build a new cookie. This returns a CookieBuilder that can be used to set other attribute
values.
Sourcepub fn set_expires<E: Into<Expires>>(&mut self, expires: E)
pub fn set_expires<E: Into<Expires>>(&mut self, expires: E)
Set the Expired attribute.
Sourcepub fn max_age(&self) -> Option<Duration>
pub fn max_age(&self) -> Option<Duration>
Get the MaxAge duration. This returns a std::time::Duration, if you’d like a time,
chrono or jiff specific duration use the max_age_{time,chrono,jiff} method.
Sourcepub fn max_age_secs(&self) -> Option<u64>
pub fn max_age_secs(&self) -> Option<u64>
Get the MaxAge as seconds.
Sourcepub fn set_max_age(&mut self, max_age: Duration)
pub fn set_max_age(&mut self, max_age: Duration)
Set the MaxAge attribute.
Sourcepub fn set_max_age_secs(&mut self, max_age_secs: u64)
pub fn set_max_age_secs(&mut self, max_age_secs: u64)
Set the MaxAge value in seconds.
Sourcepub fn unset_max_age(&mut self)
pub fn unset_max_age(&mut self)
Removes the MaxAge attribute.
Sourcepub fn set_domain<D: Into<Cow<'static, str>>>(&mut self, domain: D)
pub fn set_domain<D: Into<Cow<'static, str>>>(&mut self, domain: D)
Set the Domain attribute.
Sourcepub fn unset_domain(&mut self)
pub fn unset_domain(&mut self)
Removes the Domain attribute.
Sourcepub fn unset_path(&mut self)
pub fn unset_path(&mut self)
Removes the path attribute.
pub fn set_secure(&mut self, secure: bool)
pub fn set_http_only(&mut self, http_only: bool)
Sourcepub fn partitioned(&self) -> bool
pub fn partitioned(&self) -> bool
Returns if the Partitioned attribute is set.
Sourcepub fn set_partitioned(&mut self, partitioned: bool)
pub fn set_partitioned(&mut self, partitioned: bool)
Set the Partitioned flag, enabling the Partitioned attribute also enables the Secure Attribute.
Sourcepub fn set_same_site<S: Into<Option<SameSite>>>(&mut self, same_site: S)
pub fn set_same_site<S: Into<Option<SameSite>>>(&mut self, same_site: S)
Set the SameSite attribute.