pavex::cookie

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>

pub fn new<N>(name: N) -> RemovalCookie<'c>
where N: Into<Cow<'c, str>>,

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

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>

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>

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>

Converts self into a RemovalCookie with a 'static lifetime with as few allocations as possible.

§

impl<'c> RemovalCookie<'c>

Methods to set fields in a RemovalCookie.

pub fn set_name<N>(self, name: N) -> RemovalCookie<'c>
where N: Into<Cow<'c, str>>,

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>
where P: Into<Cow<'c, str>>,

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>

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>
where D: Into<Cow<'c, str>>,

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>

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>

§

fn clone(&self) -> RemovalCookie<'c>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl<'c> Debug for RemovalCookie<'c>

§

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

Formats the value using the given formatter. Read more
§

impl<'c> From<RemovalCookie<'c>> for ResponseCookie<'c>

§

fn from(value: RemovalCookie<'c>) -> ResponseCookie<'c>

Converts to this type from the input type.
§

impl<'c> From<ResponseCookieId<'c>> for RemovalCookie<'c>

§

fn from(value: ResponseCookieId<'c>) -> RemovalCookie<'c>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'c> Freeze for RemovalCookie<'c>

§

impl<'c> RefUnwindSafe for RemovalCookie<'c>

§

impl<'c> Send for RemovalCookie<'c>

§

impl<'c> Sync for RemovalCookie<'c>

§

impl<'c> Unpin for RemovalCookie<'c>

§

impl<'c> UnwindSafe for RemovalCookie<'c>

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, dst: *mut T)

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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