Coverage Report

Created: 2026-01-25 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/rustls-0.23.36/src/time_provider.rs
Line
Count
Source
1
//! The library's source of time.
2
3
use core::fmt::Debug;
4
5
use pki_types::UnixTime;
6
7
/// An object that provides the current time.
8
///
9
/// This is used to, for example, check if a certificate has expired during
10
/// certificate validation, or to check the age of a ticket.
11
pub trait TimeProvider: Debug + Send + Sync {
12
    /// Returns the current wall time.
13
    ///
14
    /// This is not required to be monotonic.
15
    ///
16
    /// Return `None` if unable to retrieve the time.
17
    fn current_time(&self) -> Option<UnixTime>;
18
}
19
20
#[derive(Debug)]
21
#[cfg(feature = "std")]
22
/// Default `TimeProvider` implementation that uses `std`
23
pub struct DefaultTimeProvider;
24
25
#[cfg(feature = "std")]
26
impl TimeProvider for DefaultTimeProvider {
27
0
    fn current_time(&self) -> Option<UnixTime> {
28
0
        Some(UnixTime::now())
29
0
    }
30
}