1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use instant::Instant;

/// Clock returns the current time.
pub trait Clock {
    fn now(&self) -> Instant;
}

/// `SystemClock` uses the system's clock to get the current time.
/// This Clock should be used for real use-cases.
#[derive(Debug, Default)]
pub struct SystemClock {}

impl Clock for SystemClock {
    fn now(&self) -> Instant {
        Instant::now()
    }
}