Trait rtic_time::Monotonic

source ·
pub trait Monotonic {
    type Instant: Ord + Copy + Add<Self::Duration, Output = Self::Instant> + Sub<Self::Duration, Output = Self::Instant> + Sub<Self::Instant, Output = Self::Duration>;
    type Duration: Copy;

    // Required methods
    fn now() -> Self::Instant;
    async fn delay(duration: Self::Duration);
    async fn delay_until(instant: Self::Instant);
    async fn timeout_at<F: Future>(
        instant: Self::Instant,
        future: F
    ) -> Result<F::Output, TimeoutError>;
    async fn timeout_after<F: Future>(
        duration: Self::Duration,
        future: F
    ) -> Result<F::Output, TimeoutError>;
}
Expand description

§A monotonic clock / counter definition.

§Correctness

The trait enforces that proper time-math is implemented between Instant and Duration. This is a requirement on the time library that the user chooses to use.

Required Associated Types§

source

type Instant: Ord + Copy + Add<Self::Duration, Output = Self::Instant> + Sub<Self::Duration, Output = Self::Instant> + Sub<Self::Instant, Output = Self::Duration>

The type for instant, defining an instant in time.

Note: In all APIs in RTIC that use instants from this monotonic, this type will be used.

source

type Duration: Copy

The type for duration, defining a duration of time.

Note: In all APIs in RTIC that use duration from this monotonic, this type will be used.

Required Methods§

source

fn now() -> Self::Instant

Get the current time.

source

async fn delay(duration: Self::Duration)

Delay for some duration of time.

source

async fn delay_until(instant: Self::Instant)

Delay to some specific time instant.

source

async fn timeout_at<F: Future>( instant: Self::Instant, future: F ) -> Result<F::Output, TimeoutError>

Timeout at a specific time.

source

async fn timeout_after<F: Future>( duration: Self::Duration, future: F ) -> Result<F::Output, TimeoutError>

Timeout after a specific duration.

Object Safety§

This trait is not object safe.

Implementors§