pub trait Timer {
// Required methods
fn now(&self) -> Instant;
fn sleep_until(&self, deadline: Instant) -> impl Future<Output = ()>;
// Provided method
fn sleep(&self, duration: Duration) -> impl Future<Output = ()> { ... }
}Expand description
Monotonic time, and the ability to wait for it.
“Monotonic” is the whole requirement: it must never go backwards, and it must not jump when somebody sets the wall clock. Matter’s deadlines are all durations from now.
Required Methods§
Sourcefn sleep_until(&self, deadline: Instant) -> impl Future<Output = ()>
fn sleep_until(&self, deadline: Instant) -> impl Future<Output = ()>
Completes at deadline, or immediately if it has passed.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".