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§
Required Methods§
Sourcefn elapsed_since(&self, instant: Self::Instant) -> Self::Duration
fn elapsed_since(&self, instant: Self::Instant) -> Self::Duration
Calculate the duration elapsed since the given instant.
Sourcefn has_elapsed(&self, instant: Self::Instant, duration: &Self::Duration) -> bool
fn has_elapsed(&self, instant: Self::Instant, duration: &Self::Duration) -> bool
Check if a duration has passed since the given instant.
Sourcefn duration_from_millis(&self, millis: u64) -> Self::Duration
fn duration_from_millis(&self, millis: u64) -> Self::Duration
Create a duration from milliseconds.
Implementors§
Source§impl Clock for RpHalClock
Implement the Clock trait for RpHalClock
impl Clock for RpHalClock
Implement the Clock trait for RpHalClock