Crate waiter_trait

Crate waiter_trait 

Source
Expand description

Traits used to wait and timeout in a no-std embedded system.

§Features

  • std: Disabled by default.

§Usage

  1. New a Waiter or TimedWaiter implementation.
  2. Call start() to get a WaiterStatus implementation.
  3. Call timeout() to check if the time limit expires.
    1. Interval::interval is usually called in timeout() before the time limit expires. It also depends on your implementation.
  4. Call restart() to reset the timeout condition if necessary.

§Example

use waiter_trait::prelude::*;

fn foo(waiter: impl Waiter) {
    let mut t = waiter.start();
    loop {
        // Wait for something.

        // Reset if it's necessary.
        t.restart();

        if t.timeout() {
            break;
        }
    }
}

§Pre-implemented

§Implement Your Own

For developers, you can choose one of the following options.

Re-exports§

pub use fugit;

Modules§

prelude

Structs§

Counter
The timeout condition is independent of time and is determined solely by the number of times timeout() is called.
CounterInstance
NonInterval
Interval implementation that does nothing
StdInterval
Interval implementation for std.
StdWaiter
Waiter implementation for std.
StdWaiterStatus
WaiterStatus implementation for std.
TickDelay
DelayNs implementation
TickWaiter
Waiter implementation for embedded system.
TickWaiterStatus
TimedTickWaiter
Waiter implementation for embedded system.
TimedTickWaiterStatus

Traits§

DelayNs
Delay with up to nanosecond precision.
Interval
It is usually called at WaiterStatus::timeout before the time limit expires. It can be implemented for yield, sleep or do nothing.
Num
TickInstant
TimedWaiter
The difference from Waiter is that it supports setting timeout at start().
Waiter
WaiterStatus

Type Aliases§

MicrosDurationU32
Alias for microsecond duration (u32 backing storage)