pub trait Clock: Send + Sync {
// Required methods
fn now(&self) -> Duration;
fn sleep(
&self,
duration: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>;
// Provided method
fn sleep_because(
&self,
duration: Duration,
cause: WaitCause,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>> { ... }
}Expand description
A source of monotonic time and of waits measured against it.
Required Methods§
Provided Methods§
Sourcefn sleep_because(
&self,
duration: Duration,
cause: WaitCause,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
fn sleep_because( &self, duration: Duration, cause: WaitCause, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
sleep, for a wait whose reason is cause — the fixed word a plugin
names its waits by, such as the limit it is pacing under.
A clock that keeps a record of what waited and why — a test’s simulated one — keeps the
cause beside the wait; every other clock waits exactly as sleep does, which is what
this is defaulted to.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".