Struct jwt_compact::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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

Creates an empty claims instance.

Creates a new instance with the provided custom claims.

Sets the expiration claim so that the token has the specified duration. The current timestamp is taken from options.

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.

Sets the nbf claim.

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).

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.