pub struct Authenticated<T> { /* private fields */ }Expand description
Data authenticated with an HMAC
Use to_data() to access the data locally.
Serialization is supported for transfer to a remote system as JSON Web Token.
The remote system can verify and read the data from the data claim:
use jsonwebtoken::{decode, DecodingKey, Validation, Algorithm};
use serde::Deserialize;
#[derive(Deserialize, Clone, Debug)]
struct Claims {
data: T,
exp: u64,
}
let data = decode::<Claims>(
&jwt,
&DecodingKey::from_secret(hmac_key),
&Validation::new(Algorithm::HS256),
)?.claims.data;Implementations§
Source§impl<T> Authenticated<T>where
T: Serialize,
impl<T> Authenticated<T>where
T: Serialize,
Source§impl<T> Authenticated<T>where
T: for<'de> Deserialize<'de> + Clone,
impl<T> Authenticated<T>where
T: for<'de> Deserialize<'de> + Clone,
Trait Implementations§
Source§impl<T: Clone> Clone for Authenticated<T>
impl<T: Clone> Clone for Authenticated<T>
Source§fn clone(&self) -> Authenticated<T>
fn clone(&self) -> Authenticated<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for Authenticated<T>
impl<T: Debug> Debug for Authenticated<T>
Source§impl<'de, T> Deserialize<'de> for Authenticated<T>where
T: for<'t> Deserialize<'t> + Clone,
impl<'de, T> Deserialize<'de> for Authenticated<T>where
T: for<'t> Deserialize<'t> + Clone,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> FromStr for Authenticated<T>where
T: for<'de> Deserialize<'de> + Clone,
impl<T> FromStr for Authenticated<T>where
T: for<'de> Deserialize<'de> + Clone,
Source§impl<T: PartialEq> PartialEq for Authenticated<T>
impl<T: PartialEq> PartialEq for Authenticated<T>
Source§fn eq(&self, other: &Authenticated<T>) -> bool
fn eq(&self, other: &Authenticated<T>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<T> Serialize for Authenticated<T>
impl<T> Serialize for Authenticated<T>
impl<T: Eq> Eq for Authenticated<T>
impl<T> StructuralPartialEq for Authenticated<T>
Auto Trait Implementations§
impl<T> Freeze for Authenticated<T>
impl<T> RefUnwindSafe for Authenticated<T>where
T: RefUnwindSafe,
impl<T> Send for Authenticated<T>where
T: Send,
impl<T> Sync for Authenticated<T>where
T: Sync,
impl<T> Unpin for Authenticated<T>where
T: Unpin,
impl<T> UnsafeUnpin for Authenticated<T>
impl<T> UnwindSafe for Authenticated<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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