walker-common 0.17.0

Common functionality for SBOM and CSAF walker
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use chrono::Utc;

/// Check if something expired or expires soon.
pub trait Expires {
    /// Check if the resource expires before the duration elapsed.
    fn expires_before(&self, duration: time::Duration) -> bool;
}

impl Expires for openid::TemporalBearerGuard {
    fn expires_before(&self, duration: time::Duration) -> bool {
        match self.expires_at() {
            Some(expires) => (expires - Utc::now()).num_seconds() <= duration.whole_seconds(),
            None => false,
        }
    }
}