pub struct Timer { /* private fields */ }Expand description
A future that completes at a specified Instant.
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn at(expires_at: Instant) -> Self
pub fn at(expires_at: Instant) -> Self
Expire at specified Instant Will expire immediately if the Instant is in the past.
Sourcepub fn after(duration: Duration) -> Self
pub 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;
}Sourcepub fn after_ticks(ticks: u64) -> Self
pub fn after_ticks(ticks: u64) -> Self
Expire after the specified number of ticks.
This method is a convenience wrapper for calling Timer::after(Duration::from_ticks()).
For more details, refer to Timer::after() and Duration::from_ticks().
Sourcepub fn after_nanos(nanos: u64) -> Self
pub fn after_nanos(nanos: u64) -> Self
Expire after the specified number of nanoseconds.
This method is a convenience wrapper for calling Timer::after(Duration::from_nanos()).
For more details, refer to Timer::after() and Duration::from_nanos().
Sourcepub fn after_micros(micros: u64) -> Self
pub fn after_micros(micros: u64) -> Self
Expire after the specified number of microseconds.
This method is a convenience wrapper for calling Timer::after(Duration::from_micros()).
For more details, refer to Timer::after() and Duration::from_micros().
Sourcepub fn after_millis(millis: u64) -> Self
pub fn after_millis(millis: u64) -> Self
Expire after the specified number of milliseconds.
This method is a convenience wrapper for calling Timer::after(Duration::from_millis()).
For more details, refer to Timer::after and Duration::from_millis().
Sourcepub fn after_secs(secs: u64) -> Self
pub fn after_secs(secs: u64) -> Self
Expire after the specified number of seconds.
This method is a convenience wrapper for calling Timer::after(Duration::from_secs()).
For more details, refer to Timer::after and Duration::from_secs().