Struct RemovalCookie
pub struct RemovalCookie<'c> { /* private fields */ }
Expand description
A ResponseCookie
that, when sent to the client,
removes a cookie with the same ResponseCookieId
from the client’s machine, if it exists.
See ResponseCookies
’s documentation for more details on cookie deletion.
Implementations§
§impl<'c> RemovalCookie<'c>
impl<'c> RemovalCookie<'c>
pub fn new<N>(name: N) -> RemovalCookie<'c>
pub fn new<N>(name: N) -> RemovalCookie<'c>
Creates a new RemovalCookie
with the given name.
§Example
use biscotti::RemovalCookie;
let removal = RemovalCookie::new("name")
.set_path("/");
assert_eq!(removal.name(), "name");
assert_eq!(removal.path(), Some("/"));
assert_eq!(removal.domain(), None);
pub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the name of self
.
§Example
use biscotti::RemovalCookie;
let c = RemovalCookie::new("name");
assert_eq!(c.name(), "name");
pub fn path(&self) -> Option<&str>
pub fn path(&self) -> Option<&str>
Returns the Path
of the RemovalCookie
if one was specified.
§Example
use biscotti::RemovalCookie;
let c = RemovalCookie::new("name");
assert_eq!(c.path(), None);
let c = RemovalCookie::new("name").set_path("/");
assert_eq!(c.path(), Some("/"));
let c = RemovalCookie::new("name").set_path("/sub");
assert_eq!(c.path(), Some("/sub"));
pub fn domain(&self) -> Option<&str>
pub fn domain(&self) -> Option<&str>
Returns the Domain
of the RemovalCookie
if one was specified.
This does not consider whether the Domain
is valid; validation is left
to higher-level libraries, as needed. However, if the Domain
starts
with a leading .
, the leading .
is stripped.
§Example
use biscotti::RemovalCookie;
let c = RemovalCookie::new("name");
assert_eq!(c.domain(), None);
let c = RemovalCookie::new("name").set_domain("crates.io");
assert_eq!(c.domain(), Some("crates.io"));
let c = RemovalCookie::new("name").set_domain(".crates.io");
assert_eq!(c.domain(), Some("crates.io"));
// Note that `..crates.io` is not a valid domain.
let c = RemovalCookie::new("name").set_domain("..crates.io");
assert_eq!(c.domain(), Some(".crates.io"));
pub fn into_owned(self) -> RemovalCookie<'static>
pub fn into_owned(self) -> RemovalCookie<'static>
Converts self
into a RemovalCookie
with a 'static
lifetime with as few
allocations as possible.
§impl<'c> RemovalCookie<'c>
impl<'c> RemovalCookie<'c>
Methods to set fields in a RemovalCookie
.
pub fn set_name<N>(self, name: N) -> RemovalCookie<'c>
pub fn set_name<N>(self, name: N) -> RemovalCookie<'c>
Sets the name of this removal cookie, replacing the current name. It returns the modified removal cookie.
§Example
use biscotti::RemovalCookie;
let mut c = RemovalCookie::new("name");
assert_eq!(c.name(), "name");
c = c.set_name("foo");
assert_eq!(c.name(), "foo");
pub fn set_path<P>(self, path: P) -> RemovalCookie<'c>
pub fn set_path<P>(self, path: P) -> RemovalCookie<'c>
Sets the path property of the removal cookie to path
.
It returns the modified removal cookie.
§Example
use biscotti::RemovalCookie;
let mut c = RemovalCookie::new("name");
assert_eq!(c.path(), None);
c = c.set_path("/");
assert_eq!(c.path(), Some("/"));
pub fn unset_path(self) -> RemovalCookie<'c>
pub fn unset_path(self) -> RemovalCookie<'c>
Unsets the path
property of the removal cookie.
It returns the modified removal cookie.
§Example
use biscotti::RemovalCookie;
let mut c = RemovalCookie::new("name");
assert_eq!(c.path(), None);
c = c.set_path("/");
assert_eq!(c.path(), Some("/"));
c = c.unset_path();
assert_eq!(c.path(), None);
pub fn set_domain<D>(self, domain: D) -> RemovalCookie<'c>
pub fn set_domain<D>(self, domain: D) -> RemovalCookie<'c>
Sets the domain
of self
to domain
.
§Example
use biscotti::RemovalCookie;
let mut c = RemovalCookie::new("name");
assert_eq!(c.domain(), None);
c = c.set_domain("rust-lang.org");
assert_eq!(c.domain(), Some("rust-lang.org"));
pub fn unset_domain(self) -> RemovalCookie<'c>
pub fn unset_domain(self) -> RemovalCookie<'c>
Unsets the domain
of self
.
§Example
use biscotti::RemovalCookie;
let mut c = RemovalCookie::new("name");
assert_eq!(c.domain(), None);
c = c.set_domain("rust-lang.org");
assert_eq!(c.domain(), Some("rust-lang.org"));
c = c.unset_domain();
assert_eq!(c.domain(), None);
Trait Implementations§
§impl<'c> Clone for RemovalCookie<'c>
impl<'c> Clone for RemovalCookie<'c>
§fn clone(&self) -> RemovalCookie<'c>
fn clone(&self) -> RemovalCookie<'c>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more