Trait mendes::cookies::AppWithCookies
source · pub trait AppWithCookies: AppWithAeadKey {
// Provided methods
fn cookie<T: CookieData + DeserializeOwned>(
&self,
headers: &HeaderMap
) -> Option<T> { ... }
fn set_cookie<T: CookieData + Serialize>(
&self,
headers: &mut HeaderMap,
data: Option<T>
) -> Result<(), Error> { ... }
fn set_cookie_header<T: CookieData + Serialize>(
&self,
data: Option<T>
) -> Result<HeaderValue, Error> { ... }
fn set_cookie_from_parts(
&self,
name: &str,
value: Option<impl Serialize>,
meta: &CookieMeta<'_>
) -> Result<HeaderValue, Error> { ... }
}
application
and cookies
only.Expand description
Cookie manipulation methods, contingent upon the Application
’s access to an AEAD Key
Provided Methods§
Extract cookie from the given HeaderMap
using this Application
’s Key
Finds the first Cookie
header whose name matches the given type T
and
whose value can be successfully decoded, decrypted and has not expired.
Set cookie value by appending a Set-Cookie
to the given HeaderMap
If data
is Some
, a new value will be set. If the value is None
, an
empty value is set with an expiry time in the past, causing the cookie
to be deleted in compliant clients.
Encode and encrypt the cookie’s value into a Set-Cookie
HeaderValue
If data
is Some
, a new value will be set. If the value is None
, an
empty value is set with an expiry time in the past, causing the cookie
to be deleted in compliant clients.
Assemble a Set-Cookie
HeaderValue
from parts