Trait linux_embedded_hal::CountDown 
source · [−]pub trait CountDown {
    type Error: Debug;
    type Time;
    fn start<T>(&mut self, count: T) -> Result<(), Self::Error>
    where
        T: Into<Self::Time>;
    fn wait(&mut self) -> Result<(), Self::Error>;
}Expand description
A count down timer
Note that this is borrowed from embedded-hal 0.2.x and will be in use until the 1.x version provides one.
Contract
self.start(count); block!(self.wait());MUST block for AT LEAST the time specified bycount.
Note that the implementer doesn’t necessarily have to be a downcounting timer; it could also be an upcounting timer as long as the above contract is upheld.
Examples
You can use this timer to create delays
use std::time::Duration;
use nb::block;
use linux_embedded_hal::{CountDown, SysTimer};
fn main() {
    let mut led: Led = {
        // ..
    };
    let mut timer = SysTimer::new();
    Led.on();
    timer.start(Duration::from_millis(1000)).unwrap();
    block!(timer.wait()); // blocks for 1 second
    Led.off();
}
Required Associated Types
An enumeration of CountDown errors.
For infallible implementations, will be Infallible
Required Methods
Starts a new count down
Non-blockingly “waits” until the count down finishes
Contract
- If 
Self: Periodic, the timer will start a new count down right after the last one finishes. - Otherwise the behavior of calling 
waitafter the last call returnedOkis UNSPECIFIED. Implementers are suggested to panic on this scenario to signal a programmer error.