Skip to main content

TimeSource

Trait TimeSource 

Source
pub trait TimeSource: Debug {
    // Required method
    fn elapsed(&self) -> Duration;
}
Expand description

A source of monotonically increasing timestamps, measured from an arbitrary start.

Implemented by MonotonicTime (real) and ManualTime (tests). The clock itself takes timestamps as arguments, so this trait exists to make “where does the time come from” an explicit choice at the call site.

Required Methods§

Source

fn elapsed(&self) -> Duration

Time elapsed since this source was created.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§