Skip to main content

Clock

Trait Clock 

Source
pub trait Clock {
    type Instant: Copy;
    type Duration: Copy;

    // Required methods
    fn now(&self) -> Self::Instant;
    fn elapsed_since(&self, instant: Self::Instant) -> Self::Duration;
    fn has_elapsed(
        &self,
        instant: Self::Instant,
        duration: &Self::Duration,
    ) -> bool;
    fn duration_from_millis(&self, millis: u64) -> Self::Duration;
}
Expand description

A trait for time-keeping implementations.

Required Associated Types§

Source

type Instant: Copy

A type representing a specific instant in time.

Source

type Duration: Copy

A type representing a duration of time

Required Methods§

Source

fn now(&self) -> Self::Instant

Get the current time.

Source

fn elapsed_since(&self, instant: Self::Instant) -> Self::Duration

Calculate the duration elapsed since the given instant.

Source

fn has_elapsed(&self, instant: Self::Instant, duration: &Self::Duration) -> bool

Check if a duration has passed since the given instant.

Source

fn duration_from_millis(&self, millis: u64) -> Self::Duration

Create a duration from milliseconds.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Clock for CoreClock

Source§

impl Clock for EmbassyClock

Available on crate feature embassy only.
Source§

impl Clock for RpHalClock

Implement the Clock trait for RpHalClock

Source§

type Instant = Instant<u64, 1, 1000000>

Source§

type Duration = Duration<u64, 1, 1000000>