#[non_exhaustive]pub struct TimeOptions {
pub now: Option<DateTime<Utc>>,
pub leeway: Duration,
}Available on crate feature
vc only.Expand description
The validation time and the clock skew allowed around it.
§Examples
use std::time::Duration;
use chrono::{TimeZone as _, Utc};
use identity_kit::vc::validation::TimeOptions;
let fixed = TimeOptions::at(Utc.with_ymd_and_hms(2019, 11, 6, 0, 0, 0).unwrap())
.with_leeway(Duration::from_secs(60));
assert_eq!(fixed.now().to_rfc3339(), "2019-11-06T00:00:00+00:00");
assert_eq!(fixed.leeway, Duration::from_secs(60));
assert!(TimeOptions::default().now() > fixed.now());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.now: Option<DateTime<Utc>>The validation time; the current time when None.
leeway: DurationHow far nbf, exp and iat may miss the validation time and still pass; zero by
default.
Implementations§
Source§impl TimeOptions
impl TimeOptions
Sourcepub fn with_leeway(self, leeway: Duration) -> Self
pub fn with_leeway(self, leeway: Duration) -> Self
These options with leeway.
Sourcepub fn check(
&self,
not_before: Option<DateTime<Utc>>,
expires: Option<DateTime<Utc>>,
issued_at: Option<DateTime<Utc>>,
) -> Result<(), ValidationError>
pub fn check( &self, not_before: Option<DateTime<Utc>>, expires: Option<DateTime<Utc>>, issued_at: Option<DateTime<Utc>>, ) -> Result<(), ValidationError>
Checks that now is within [not_before, expires) with the leeway, and that
issued_at is not in the future.
§Errors
ValidationError::NotYetValid, ValidationError::Expired or
ValidationError::IssuedInFuture.
Sourcepub fn check_claims(&self, claims: &JwtClaims) -> Result<(), ValidationError>
pub fn check_claims(&self, claims: &JwtClaims) -> Result<(), ValidationError>
Checks the registered time claims of claims: nbf, exp and iat.
§Errors
As check, or ValidationError::Credential for a claim out of
range.
Trait Implementations§
Source§impl Clone for TimeOptions
impl Clone for TimeOptions
impl Copy for TimeOptions
Source§impl Debug for TimeOptions
impl Debug for TimeOptions
Source§impl Default for TimeOptions
impl Default for TimeOptions
impl Eq for TimeOptions
Source§impl PartialEq for TimeOptions
impl PartialEq for TimeOptions
impl StructuralPartialEq for TimeOptions
Auto Trait Implementations§
impl Freeze for TimeOptions
impl RefUnwindSafe for TimeOptions
impl Send for TimeOptions
impl Sync for TimeOptions
impl Unpin for TimeOptions
impl UnsafeUnpin for TimeOptions
impl UnwindSafe for TimeOptions
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.