Struct jwt_compact::TimeOptions[][src]

#[non_exhaustive]
pub struct TimeOptions<F = fn() -> DateTime<Utc>> { pub leeway: Duration, pub clock_fn: F, }
Expand description

Time-related options for token creation and validation.

If the clock crate feature is on (and it’s on by default), TimeOptions can be created using the Default impl or Self::from_leeway(). If the feature is off, you can still create options using a generic constructor.

Examples

// Default options.
let default_options = TimeOptions::default();
let options_with_custom_leeway =
    TimeOptions::from_leeway(Duration::seconds(5));
// Options that have a fixed time. Can be useful for testing.
let clock_time = Utc::now();
let options_with_stopped_clock =
    TimeOptions::new(Duration::seconds(10), move || clock_time);

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.
leeway: Duration

Leeway to use during validation.

clock_fn: F

Source of the current timestamps.

Implementations

Creates options based on the specified time leeway and clock function.

This is supported on crate feature clock only.

Creates options based on the specified time leeway. The clock source is Utc::now().

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

Creates options with a default leeway (60 seconds) and the Utc::now() clock.

This impl is supported on crate feature clock only.

Returns the “default value” for a type. 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.