Struct TimerListener

Source
pub struct TimerListener { /* private fields */ }
Expand description

Timer Listener

Used to create Timers, which may be .awaited to wait for a specific time. See AsyncListeners to get one.

Implementations§

Source§

impl TimerListener

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn every_hz(&self, hz: u32) -> Interval

Creates a Stream that triggers with the specified number of events per second.

Source

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.

Source

pub fn every(&self, dur: Duration) -> Interval

Creates a Stream that triggers every 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.

Source

pub fn every_ticks(&self, ticks: u32) -> Interval

Creates a Stream that triggers every specified number of ticks. Problems will occur when sleeping for more than 2^31 ticks, which is about 18 hours.

Trait Implementations§

Source§

impl Default for TimerListener

Source§

fn default() -> TimerListener

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.