pub struct Cookies { /* private fields */ }Expand description
A parsed on-demand cookie jar.
Implementations§
Source§impl Cookies
impl Cookies
Sourcepub fn signed<'a>(&self, key: &'a Key) -> SignedCookies<'a>
pub fn signed<'a>(&self, key: &'a Key) -> SignedCookies<'a>
Returns a child SignedCookies jar for interations with signed by the key cookies.
§Example:
use cookie::{Cookie, Key};
use tower_cookies::Cookies;
let cookies = Cookies::default();
let key = Key::generate();
let signed = cookies.signed(&key);
let foo = Cookie::new("foo", "bar");
signed.add(foo.clone());
assert_eq!(signed.get("foo"), Some(foo.clone()));
assert_ne!(cookies.get("foo"), Some(foo));Sourcepub fn private<'a>(&self, key: &'a Key) -> PrivateCookies<'a>
pub fn private<'a>(&self, key: &'a Key) -> PrivateCookies<'a>
Returns a child PrivateCookies jar for encrypting and decrypting cookies.
§Example:
use cookie::{Cookie, Key};
use tower_cookies::Cookies;
let cookies = Cookies::default();
let key = Key::generate();
let private = cookies.private(&key);
let foo = Cookie::new("foo", "bar");
private.add(foo.clone());
assert_eq!(private.get("foo"), Some(foo.clone()));
assert_ne!(cookies.get("foo"), Some(foo));Trait Implementations§
Source§impl<S> FromRequestParts<S> for Cookies
impl<S> FromRequestParts<S> for Cookies
Source§type Rejection = (StatusCode, &'static str)
type Rejection = (StatusCode, &'static str)
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§async fn from_request_parts(
parts: &mut Parts,
_state: &S,
) -> Result<Cookies, <Cookies as FromRequestParts<S>>::Rejection>
async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<Cookies, <Cookies as FromRequestParts<S>>::Rejection>
Perform the extraction.
Auto Trait Implementations§
impl Freeze for Cookies
impl !RefUnwindSafe for Cookies
impl Send for Cookies
impl Sync for Cookies
impl Unpin for Cookies
impl !UnwindSafe for Cookies
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§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§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.