pub trait Clock:
Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn current(&self) -> SystemTime;
fn sleep(
&self,
duration: Duration,
) -> impl Future<Output = ()> + Send + 'static;
fn sleep_until(
&self,
deadline: SystemTime,
) -> impl Future<Output = ()> + Send + 'static;
}
Expand description
Interface that any task scheduler must implement to provide time-based operations.
It is necessary to mock time to provide deterministic execution of arbitrary tasks.
Required Methods§
sourcefn current(&self) -> SystemTime
fn current(&self) -> SystemTime
Returns the current time.
sourcefn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static
fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static
Sleep for the given duration.
sourcefn sleep_until(
&self,
deadline: SystemTime,
) -> impl Future<Output = ()> + Send + 'static
fn sleep_until( &self, deadline: SystemTime, ) -> impl Future<Output = ()> + Send + 'static
Sleep until the given deadline.
Object Safety§
This trait is not object safe.