Skip to content

Commit

Permalink
feat: sugar functions for valid time
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Oct 21, 2023
1 parent e8958e9 commit f4ac1ac
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ pub struct Keystore {
pub refresh_expires: Instant,
}

impl Keystore {
/// The amount of time the access token is valid for. A duration of zero means expired.
pub fn access_token_valid_for(&self) -> Duration {
self.access_expires
.saturating_duration_since(instant::Instant::now())
}

/// The amount of time the refresh token is valid for. A duration of zero means expired.
pub fn refresh_token_valid_for(&self) -> Duration {
self.refresh_expires
.saturating_duration_since(instant::Instant::now())
}
}

#[derive(Resource, Debug, Clone)]
pub struct KeyRotationSettings {
/// The amount of time before the rotation attempt times out
Expand Down

0 comments on commit f4ac1ac

Please sign in to comment.