pub trait Timer: Future {
// Required method
fn after(duration: Duration) -> Self;
}Expand description
The trait to replace the embassy_time::Timer in code to allow the MockTimer to
be used in its place for tests.
Required Methods§
Sourcefn after(duration: Duration) -> Self
fn after(duration: Duration) -> Self
Wrapper for embassy_time::Timer::after().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Timer for Timer
impl Timer for Timer
Source§fn after(duration: Duration) -> Self
fn after(duration: Duration) -> Self
Expire after specified Duration.
This can be used as a sleep abstraction.
Example:
use embassy_time::{Duration, Timer};
#[embassy_executor::task]
async fn demo_sleep_seconds() {
// suspend this task for one second.
Timer::after(Duration::from_secs(1)).await;
}