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, F> Cookies for Map<J, F>
impl<J, F> Cookies for Map<J, F>
Source§fn get(&self, name: &str) -> Option<Cookie<'static>>
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)
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 moreSource§fn remove<C: Into<Cookie<'static>>>(&self, cookie: C)
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 moreSource§fn signed(self, key: &Key) -> SignedJar<'_, Self>where
Self: Sized,
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,
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>
fn map<F>(self, f: F) -> Map<Self, F>
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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.impl<J: Copy, F: Copy> Copy for Map<J, F>
Auto Trait Implementations§
impl<J, F> Freeze for Map<J, F>
impl<J, F> RefUnwindSafe for Map<J, F>where
J: RefUnwindSafe,
F: RefUnwindSafe,
impl<J, F> Send for Map<J, F>
impl<J, F> Sync for Map<J, F>
impl<J, F> Unpin for Map<J, F>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more