[−][src]Struct jwt_compact::Claims
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
expiration_date: Option<DateTime<Utc>>
Expiration date of the token.
not_before: Option<DateTime<Utc>>
Minimum date at which token is valid.
issued_at: Option<DateTime<Utc>>
Date of token issuance.
custom: T
Custom claims.
Methods
impl Claims<Empty>
[src]
impl<T> Claims<T>
[src]
pub fn new(custom_claims: T) -> Self
[src]
Creates a new instance with the provided custom claims.
pub fn set_duration(self, duration: Duration) -> Self
[src]
Sets expiration_date
claim so that the token has the specified duration
.
pub fn set_duration_and_issuance(self, duration: Duration) -> Self
[src]
Atomically sets issued_at
and expiration_date
claims: first to the current time,
and the second to match the specified duration
of the token.
pub fn set_not_before(self, moment: DateTime<Utc>) -> Self
[src]
Sets the nbf
claim.
pub fn validate_expiration(
&self,
options: TimeOptions
) -> Result<&Self, ValidationError>
[src]
&self,
options: TimeOptions
) -> Result<&Self, ValidationError>
Validates the expiration claim.
This method will return an error if the claims do not feature an expiration date,
or if it is in the past (subject to the provided options
).
pub fn validate_maturity(
&self,
options: TimeOptions
) -> Result<&Self, ValidationError>
[src]
&self,
options: TimeOptions
) -> Result<&Self, ValidationError>
Validates the maturity date (nbf
claim).
This method will return an error if the claims do not feature a maturity date,
or if it is in the future (subject to the provided options
).
Trait Implementations
impl<T: PartialEq> PartialEq<Claims<T>> for Claims<T>
[src]
impl<T: Clone> Clone for Claims<T>
[src]
fn clone(&self) -> Claims<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Claims<T>
[src]
impl<T> Serialize for Claims<T> where
T: Serialize,
[src]
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de, T> Deserialize<'de> for Claims<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl<T> Send for Claims<T> where
T: Send,
T: Send,
impl<T> Unpin for Claims<T> where
T: Unpin,
T: Unpin,
impl<T> Sync for Claims<T> where
T: Sync,
T: Sync,
impl<T> UnwindSafe for Claims<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for Claims<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> Same<T> for T
type Output = T
Should always be Self