Struct Timer
pub struct Timer { /* private fields */ }Expand description
A future that completes at a specified Instant.
Implementations§
§impl Timer
impl Timer
pub fn at(expires_at: Instant) -> Timer ⓘ
pub fn at(expires_at: Instant) -> Timer ⓘ
Expire at specified Instant Will expire immediately if the Instant is in the past.
pub fn after(duration: Duration) -> Timer ⓘ
pub fn after(duration: Duration) -> Timer ⓘ
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;
}pub fn after_ticks(ticks: u64) -> Timer ⓘ
pub fn after_ticks(ticks: u64) -> Timer ⓘ
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().
pub fn after_nanos(nanos: u64) -> Timer ⓘ
pub fn after_nanos(nanos: u64) -> Timer ⓘ
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().
pub fn after_micros(micros: u64) -> Timer ⓘ
pub fn after_micros(micros: u64) -> Timer ⓘ
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().
pub fn after_millis(millis: u64) -> Timer ⓘ
pub fn after_millis(millis: u64) -> Timer ⓘ
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().
pub fn after_secs(secs: u64) -> Timer ⓘ
pub fn after_secs(secs: u64) -> Timer ⓘ
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().
Trait Implementations§
impl Unpin for Timer
Auto Trait Implementations§
impl Freeze for Timer
impl RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f. Read more§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll will never again be called once it has
completed. This method can be used to turn any Future into a
FusedFuture. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = ()>.§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = Never>.