Skip to main content

Map

Struct Map 

Source
pub struct Map<J, F> { /* private fields */ }
Expand description

A Cookies adapter that applies a transform to every cookie written through it.

Create it with Cookies::map. The closure changes the cookie before it reaches the wrapped jar.

The closure runs for both add and remove, so removals receive the same path and domain attributes as writes. Reads pass through unchanged.

Trait Implementations§

Source§

impl<J: Clone, F: Clone> Clone for Map<J, F>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<J, F> Cookies for Map<J, F>
where J: Cookies, F: Fn(&mut Cookie<'static>),

Source§

fn get(&self, name: &str) -> Option<Cookie<'static>>

Returns the cookie named name, or None if it is absent (or, for signed/encrypted jars, fails to verify).
Source§

fn add<C: Into<Cookie<'static>>>(&self, cookie: C)

Adds cookie. It is serialized into a Set-Cookie response header once the cookie router layer handles the response. Read more
Source§

fn remove<C: Into<Cookie<'static>>>(&self, cookie: C)

Removes cookie. If the request carried an original cookie with the same name, an expiring removal cookie is sent. Pass the same Path/ Domain the cookie was set with. Read more
Source§

fn signed(self, key: &Key) -> SignedJar<'_, Self>
where Self: Sized,

Wraps this jar so signed cookies are written and verified with key.
Source§

fn private(self, key: &Key) -> PrivateJar<'_, Self>
where Self: Sized,

Wraps this jar so cookies are encrypted and decrypted with key.
Source§

fn map<F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: Fn(&mut Cookie<'static>),

Wraps this jar so every added cookie is passed through f before being stored. Use this for custom attribute changes.
Source§

fn override_prefix_host(self) -> Prefixed<Self>
where Self: Sized,

Forces the __Host- prefix and its required attributes (Secure, Path=/, no Domain) on every added cookie.
Source§

fn default_prefix_host(self) -> Prefixed<Self>
where Self: Sized,

Applies the __Host- prefix, filling its required attributes only when the cookie does not already set them.
Source§

fn override_prefix_secure(self) -> Prefixed<Self>
where Self: Sized,

Forces the __Secure- prefix and its required Secure attribute on every added cookie.
Source§

fn default_prefix_secure(self) -> Prefixed<Self>
where Self: Sized,

Applies the __Secure- prefix, setting Secure only when the cookie does not already set it.
Source§

fn override_secure( self, value: bool, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets Secure on every added cookie, overriding any existing value.
Source§

fn default_secure(self, value: bool) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets Secure on added cookies that do not already specify it.
Source§

fn override_http_only( self, value: bool, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets HttpOnly on every added cookie, overriding any existing value.
Source§

fn default_http_only( self, value: bool, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets HttpOnly on added cookies that do not already specify it.
Source§

fn override_same_site( self, value: SameSite, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets SameSite on every added cookie, overriding any existing value.
Source§

fn default_same_site( self, value: SameSite, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets SameSite on added cookies that do not already specify it.
Source§

fn override_path( self, value: impl Into<String>, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets Path on every added cookie, overriding any existing value.
Source§

fn default_path( self, value: impl Into<String>, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets Path on added cookies that do not already specify it.
Source§

fn override_domain( self, value: impl Into<String>, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets Domain on every added cookie, overriding any existing value.
Source§

fn default_domain( self, value: impl Into<String>, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets Domain on added cookies that do not already specify it.
Source§

fn override_max_age( self, value: Duration, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets Max-Age on every added cookie, overriding any existing value.
Source§

fn default_max_age( self, value: Duration, ) -> Map<Self, impl Fn(&mut Cookie<'static>)>
where Self: Sized,

Sets Max-Age on added cookies that do not already specify it.
Source§

impl<J: Copy, F: Copy> Copy for Map<J, F>

Source§

impl<J: Debug, F: Debug> Debug for Map<J, F>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<J, F> Freeze for Map<J, F>
where J: Freeze, F: Freeze,

§

impl<J, F> RefUnwindSafe for Map<J, F>

§

impl<J, F> Send for Map<J, F>
where J: Send, F: Send,

§

impl<J, F> Sync for Map<J, F>
where J: Sync, F: Sync,

§

impl<J, F> Unpin for Map<J, F>
where J: Unpin, F: Unpin,

§

impl<J, F> UnsafeUnpin for Map<J, F>
where J: UnsafeUnpin, F: UnsafeUnpin,

§

impl<J, F> UnwindSafe for Map<J, F>
where J: UnwindSafe, F: UnwindSafe,

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> CloneAny for T
where T: Any + Clone,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

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

fn try_from(value: U) -> Result<T, !>

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

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

Source§

fn vzip(self) -> V