Trait Clock

Source
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§

Source

fn current(&self) -> SystemTime

Returns the current time.

Source

fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static

Sleep for the given duration.

Source

fn sleep_until( &self, deadline: SystemTime, ) -> impl Future<Output = ()> + Send + 'static

Sleep until the given deadline.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Clock for commonware_runtime::deterministic::Context

Source§

impl Clock for commonware_runtime::tokio::Context