[−][src]Struct cookie::SignedJar
pub struct SignedJar<'a> { /* fields omitted */ }
A child cookie jar that authenticates its cookies.
A signed child jar signs all the cookies added to it and verifies cookies
retrieved from it. Any cookies stored in a SignedJar
are assured integrity
and authenticity. In other words, clients cannot tamper with the contents of
a cookie nor can they fabricate cookie values, but the data is visible in
plaintext.
This type is only available when the secure
feature is enabled.
Methods
impl<'a> SignedJar<'a>
[src]
impl<'a> SignedJar<'a>
pub fn get(&self, name: &str) -> Option<Cookie<'static>>
[src]
pub fn get(&self, name: &str) -> Option<Cookie<'static>>
Returns a reference to the Cookie
inside this jar with the name name
and verifies the authenticity and integrity of the cookie's value,
returning a Cookie
with the authenticated value. If the cookie cannot
be found, or the cookie fails to verify, None
is returned.
Example
use cookie::{CookieJar, Cookie, Key}; let key = Key::generate(); let mut jar = CookieJar::new(); let mut signed_jar = jar.signed(&key); assert!(signed_jar.get("name").is_none()); signed_jar.add(Cookie::new("name", "value")); assert_eq!(signed_jar.get("name").unwrap().value(), "value");
pub fn add(&mut self, cookie: Cookie<'static>)
[src]
pub fn add(&mut self, cookie: Cookie<'static>)
Adds cookie
to the parent jar. The cookie's value is signed assuring
integrity and authenticity.
Example
use cookie::{CookieJar, Cookie, Key}; let key = Key::generate(); let mut jar = CookieJar::new(); jar.signed(&key).add(Cookie::new("name", "value")); assert_ne!(jar.get("name").unwrap().value(), "value"); assert!(jar.get("name").unwrap().value().contains("value")); assert_eq!(jar.signed(&key).get("name").unwrap().value(), "value");
pub fn remove(&mut self, cookie: Cookie<'static>)
[src]
pub fn remove(&mut self, cookie: Cookie<'static>)
Removes cookie
from the parent jar.
For correct removal, the passed in cookie
must contain the same path
and domain
as the cookie that was initially set.
See CookieJar::remove for more details.
Example
use cookie::{CookieJar, Cookie, Key}; let key = Key::generate(); let mut jar = CookieJar::new(); let mut signed_jar = jar.signed(&key); signed_jar.add(Cookie::new("name", "value")); assert!(signed_jar.get("name").is_some()); signed_jar.remove(Cookie::named("name")); assert!(signed_jar.get("name").is_none());
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more