Trait Host

Source
pub trait Host: Send + Send {
    // Required methods
    fn now(&mut self) -> impl Future<Output = Result<Instant>> + Send;
    fn resolution(&mut self) -> impl Future<Output = Result<Duration>> + Send;
    fn subscribe_instant(
        &mut self,
        when: Instant,
    ) -> impl Future<Output = Result<Resource<Pollable>>> + Send;
    fn subscribe_duration(
        &mut self,
        when: Duration,
    ) -> impl Future<Output = Result<Resource<Pollable>>> + Send;
}

Required Methods§

Source

fn now(&mut self) -> impl Future<Output = Result<Instant>> + Send

Read the current value of the clock.

The clock is monotonic, therefore calling this function repeatedly will produce a sequence of non-decreasing values.

Source

fn resolution(&mut self) -> impl Future<Output = Result<Duration>> + Send

Query the resolution of the clock. Returns the duration of time corresponding to a clock tick.

Source

fn subscribe_instant( &mut self, when: Instant, ) -> impl Future<Output = Result<Resource<Pollable>>> + Send

Create a pollable which will resolve once the specified instant occured.

Source

fn subscribe_duration( &mut self, when: Duration, ) -> impl Future<Output = Result<Resource<Pollable>>> + Send

Create a pollable which will resolve once the given duration has elapsed, starting at the time at which this function was called. occured.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<_T: Host + ?Sized + Send> Host for &mut _T

Source§

async fn now(&mut self) -> Result<Instant>

Read the current value of the clock.

The clock is monotonic, therefore calling this function repeatedly will produce a sequence of non-decreasing values.

Source§

async fn resolution(&mut self) -> Result<Duration>

Query the resolution of the clock. Returns the duration of time corresponding to a clock tick.

Source§

async fn subscribe_instant( &mut self, when: Instant, ) -> Result<Resource<Pollable>>

Create a pollable which will resolve once the specified instant occured.

Source§

async fn subscribe_duration( &mut self, when: Duration, ) -> Result<Resource<Pollable>>

Create a pollable which will resolve once the given duration has elapsed, starting at the time at which this function was called. occured.

Implementors§