Skip to main content

Clock

Trait Clock 

Source
pub trait Clock:
    Send
    + Sync
    + Debug {
    // Required methods
    fn now_ms(&self) -> u64;
    fn sleep(&self, duration: Duration) -> BoxFuture<'static, ()>;

    // Provided method
    fn supports_timers(&self) -> bool { ... }
}
Expand description

Time source used by the engine and nodes (retries, timeouts, elapsed time).

Required Methods§

Source

fn now_ms(&self) -> u64

Milliseconds since an arbitrary fixed origin.

Source

fn sleep(&self, duration: Duration) -> BoxFuture<'static, ()>

Wait for duration.

Provided Methods§

Source

fn supports_timers(&self) -> bool

Whether Clock::sleep actually waits. Timeouts are only enforced when true.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Clock for NoTimerClock

Source§

impl Clock for TokioClock

Available on crate feature tokio only.