Struct jwt_compact::prelude::Claims [−][src]
#[non_exhaustive]pub struct Claims<T> { pub expiration: Option<DateTime<Utc>>, pub not_before: Option<DateTime<Utc>>, pub issued_at: Option<DateTime<Utc>>, pub custom: T, }
Expand description
Claims encoded in a token.
Claims are comprised of a “standard” part (exp
, nbf
and iat
claims as per JWT spec),
and custom fields. iss
, sub
and aud
claims are not in the standard part
due to a variety of data types they can be reasonably represented by.
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct {{ .. }}
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.expiration: Option<DateTime<Utc>>
Expiration time of the token.
not_before: Option<DateTime<Utc>>
Minimum time at which token is valid.
issued_at: Option<DateTime<Utc>>
Time of token issuance.
custom: T
Custom claims.
Implementations
impl<T> Claims<T>
[src]
impl<T> Claims<T>
[src]pub fn set_duration<F>(
self,
options: &TimeOptions<F>,
duration: Duration
) -> Self where
F: Fn() -> DateTime<Utc>,
[src]
pub fn set_duration<F>(
self,
options: &TimeOptions<F>,
duration: Duration
) -> Self where
F: Fn() -> DateTime<Utc>,
[src]Sets the expiration
claim so that the token has the specified duration
.
The current timestamp is taken from options
.
pub fn set_duration_and_issuance<F>(
self,
options: &TimeOptions<F>,
duration: Duration
) -> Self where
F: Fn() -> DateTime<Utc>,
[src]
pub fn set_duration_and_issuance<F>(
self,
options: &TimeOptions<F>,
duration: Duration
) -> Self where
F: Fn() -> DateTime<Utc>,
[src]Atomically sets issued_at
and expiration
claims: first to the current time
(taken from options
), and the second to match the specified duration
of the token.
pub fn set_not_before(self, moment: DateTime<Utc>) -> Self
[src]
pub fn set_not_before(self, moment: DateTime<Utc>) -> Self
[src]Sets the nbf
claim.
pub fn validate_expiration<F>(
&self,
options: &TimeOptions<F>
) -> Result<&Self, ValidationError> where
F: Fn() -> DateTime<Utc>,
[src]
pub fn validate_expiration<F>(
&self,
options: &TimeOptions<F>
) -> Result<&Self, ValidationError> where
F: Fn() -> DateTime<Utc>,
[src]Validates the expiration claim.
This method will return an error if the claims do not feature an expiration time,
or if it is in the past (subject to the provided options
).
pub fn validate_maturity<F>(
&self,
options: &TimeOptions<F>
) -> Result<&Self, ValidationError> where
F: Fn() -> DateTime<Utc>,
[src]
pub fn validate_maturity<F>(
&self,
options: &TimeOptions<F>
) -> Result<&Self, ValidationError> where
F: Fn() -> DateTime<Utc>,
[src]Validates the maturity time (nbf
claim).
This method will return an error if the claims do not feature a maturity time,
or if it is in the future (subject to the provided options
).
Trait Implementations
impl<'de, T> Deserialize<'de> for Claims<T> where
T: Deserialize<'de>,
[src]
impl<'de, T> Deserialize<'de> for Claims<T> where
T: Deserialize<'de>,
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
impl<T> StructuralPartialEq for Claims<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Claims<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Claims<T> where
T: Send,
T: Send,
impl<T> Sync for Claims<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Claims<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Claims<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,