Struct mas_axum_utils::cookies::CookieJar
source · pub struct CookieJar { /* private fields */ }
Expand description
A cookie jar which encrypts cookies & sets secure options
Implementations§
source§impl CookieJar
impl CookieJar
sourcepub fn save<T: Serialize>(self, key: &str, payload: &T, permanent: bool) -> Self
pub fn save<T: Serialize>(self, key: &str, payload: &T, permanent: bool) -> Self
Save the given payload in a cookie
If permanent
is true, the cookie will be valid for 10 years
§Panics
Panics if the payload cannot be serialized
sourcepub fn load<T: DeserializeOwned>(
&self,
key: &str,
) -> Result<Option<T>, CookieDecodeError>
pub fn load<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<T>, CookieDecodeError>
Load and deserialize a cookie from the jar
Returns None
if the cookie is not present
§Errors
Returns an error if the cookie cannot be deserialized
Trait Implementations§
source§impl CsrfExt for CookieJar
impl CsrfExt for CookieJar
source§fn csrf_token<C, R>(self, clock: &C, rng: R) -> (CsrfToken, Self)
fn csrf_token<C, R>(self, clock: &C, rng: R) -> (CsrfToken, Self)
Get the current CSRF token out of the cookie jar, generating a new one
if necessary
source§fn verify_form<C, T>(
&self,
clock: &C,
form: ProtectedForm<T>,
) -> Result<T, CsrfError>where
C: Clock,
fn verify_form<C, T>(
&self,
clock: &C,
form: ProtectedForm<T>,
) -> Result<T, CsrfError>where
C: Clock,
Verify that the given CSRF-protected form is valid, returning the inner
value Read more
source§impl<S> FromRequestParts<S> for CookieJar
impl<S> FromRequestParts<S> for CookieJar
§type Rejection = Infallible
type Rejection = Infallible
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
source§impl IntoResponseParts for CookieJar
impl IntoResponseParts for CookieJar
§type Error = Infallible
type Error = Infallible
The type returned in the event of an error. Read more
source§fn into_response_parts(
self,
res: ResponseParts,
) -> Result<ResponseParts, Self::Error>
fn into_response_parts( self, res: ResponseParts, ) -> Result<ResponseParts, Self::Error>
Set parts of the response
source§impl SessionInfoExt for CookieJar
impl SessionInfoExt for CookieJar
fn session_info(self) -> (SessionInfo, Self)
fn update_session_info(self, info: &SessionInfo) -> Self
fn set_session(self, session: &BrowserSession) -> Selfwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for CookieJar
impl RefUnwindSafe for CookieJar
impl Send for CookieJar
impl Sync for CookieJar
impl Unpin for CookieJar
impl UnwindSafe for CookieJar
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
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Creates a filterable data provider with the given name for debugging. Read more
source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more