pub struct TimerListener { /* private fields */ }
Expand description
Timer Listener
Used to create Timer
s, which may be .await
ed to wait for a specific
time. See AsyncListeners
to get one.
Implementations§
Source§impl TimerListener
impl TimerListener
Sourcepub fn sleep_ms(&self, ms: u32) -> Timer ⓘ
pub fn sleep_ms(&self, ms: u32) -> Timer ⓘ
Sleeps for the specified number of milliseconds. Problems will occur when sleeping for more than 2^31/32768 seconds, which is about 18 hours.
Sourcepub fn sleep(&self, dur: Duration) -> Timer ⓘ
pub fn sleep(&self, dur: Duration) -> Timer ⓘ
Sleeps for the specified Duration
. Problems will occur
when sleeping for more than 2^31/32768 seconds, which is about 18 hours.
This function has a resolution of 30 μs.
Sourcepub fn sleep_ticks(&self, ticks: u32) -> Timer ⓘ
pub fn sleep_ticks(&self, ticks: u32) -> Timer ⓘ
Sleeps for the specified number of ticks. Problems will occur when sleeping for more than 2^31 ticks, which is about 18 hours.
Sourcepub fn sleep_until(&self, ticks: u32) -> Timer ⓘ
pub fn sleep_until(&self, ticks: u32) -> Timer ⓘ
Sleeps until the current number of ticks is equal to the parameter. Problems will occur when sleeping for more than 2^31 ticks in the future, which is about 18 hours.
Sourcepub async fn timeout_ms<T>(
&self,
ms: u32,
f: impl Future<Output = T>,
) -> Result<T, TimeoutError>
pub async fn timeout_ms<T>( &self, ms: u32, f: impl Future<Output = T>, ) -> Result<T, TimeoutError>
Awaits a future or times out after the specified number of milliseconds. Problems will occur when sleeping for more than 2^31/32768 seconds, which is about 18 hours.
Sourcepub async fn timeout<T>(
&self,
dur: Duration,
f: impl Future<Output = T>,
) -> Result<T, TimeoutError>
pub async fn timeout<T>( &self, dur: Duration, f: impl Future<Output = T>, ) -> Result<T, TimeoutError>
Awaits a future or times out after the specified Duration
. Problems
will occur when sleeping for more than 2^31/32768 seconds, which is
about 18 hours.
This function has a resolution of 30 μs.
Sourcepub async fn timeout_ticks<T>(
&self,
ticks: u32,
f: impl Future<Output = T>,
) -> Result<T, TimeoutError>
pub async fn timeout_ticks<T>( &self, ticks: u32, f: impl Future<Output = T>, ) -> Result<T, TimeoutError>
Awaits a future or times out after the specified number of ticks. Problems will occur when sleeping for more than 2^31 ticks, which is about 18 hours.
Sourcepub async fn timeout_until<T>(
&self,
ticks: u32,
f: impl Future<Output = T>,
) -> Result<T, TimeoutError>
pub async fn timeout_until<T>( &self, ticks: u32, f: impl Future<Output = T>, ) -> Result<T, TimeoutError>
Awaits a future or times out after the current number of ticks is equal to the parameter. Problems will occur when sleeping for more than 2^31 ticks in the future, which is about 18 hours.
Sourcepub fn every_hz(&self, hz: u32) -> Interval
pub fn every_hz(&self, hz: u32) -> Interval
Creates a Stream
that triggers with the specified number of events
per second.
Sourcepub fn every_ms(&self, ms: u32) -> Interval
pub fn every_ms(&self, ms: u32) -> Interval
Creates a Stream
that triggers every specified number of
milliseconds. Problems will occur when sleeping for more than 2^31/32768
seconds, which is about 18 hours.