backoff/clock.rs
1use instant::Instant;
2
3/// Clock returns the current time.
4pub trait Clock {
5 fn now(&self) -> Instant;
6}
7
8/// `SystemClock` uses the system's clock to get the current time.
9/// This Clock should be used for real use-cases.
10#[derive(Debug, Default, Clone)]
11pub struct SystemClock {}
12
13impl Clock for SystemClock {
14 fn now(&self) -> Instant {
15 Instant::now()
16 }
17}