pub struct Timer { /* private fields */ }
Expand description
A future that completes at a specified Instant.
Implementations§
Source§impl Timer
impl Timer
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()
.
Trait Implementations§
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read moreSource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§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 moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§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 = ()
>.Source§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
>.