Struct embassy_time::Timer
source · 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
>.