Trait Instant

Source
pub trait Instant {
    const ONE_SEC: u64;

    // Required methods
    fn now() -> Self;
    fn elapsed_time(&self) -> u64;
}
Expand description

A trait for any time source providing time measurements in milliseconds.

It is useful to let users provide an unsynchronized (!Send/!Sync) time source, unlike std’s Instant.

Required Associated Constants§

Source

const ONE_SEC: u64

One second in the instant units.

Required Methods§

Source

fn now() -> Self

Creates a new Instant representing the current time.

Source

fn elapsed_time(&self) -> u64

Returns the elapsed time since an Instant was created.

The unit depends on the Instant’s resolution, as defined by the ONE_SEC constant.

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 Instant for StdInstant

Source§

const ONE_SEC: u64 = 1_000u64

Source§

impl Instant for StdInstantMicros

Source§

const ONE_SEC: u64 = 1_000_000u64