1use core::clone::Clone;
6use core::cmp::Ord;
7use core::fmt::Debug;
8use core::future::Future;
9use core::marker::{Copy, Send, Sync};
10use core::ops::{Add, Sub};
11use core::time::Duration;
12
13pub trait Timer: Clone + Send + Sync + Debug + 'static {
14 type Sleep: Future<Output = ()>;
15
16 type Instant: Copy
17 + Debug
18 + Ord
19 + Send
20 + Sync
21 + Add<Duration, Output = Self::Instant>
22 + Sub<Duration, Output = Self::Instant>
23 + Sub<Self::Instant, Output = Duration>;
24
25 fn sleep_future(&self, duration: Duration) -> Self::Sleep;
26
27 fn now(&self) -> Self::Instant;
28}