pub trait Runtime: Clone + Send + Sync + Unpin {
    type Instant: Copy + Send + Sync + Unpin;
    type Sleep: Future<Output = ()> + Send;
    fn spawn<F>(&self, future: F)
    where
        F: Future<Output = ()> + Send + 'static
;
fn now(&self) -> Self::Instant;
fn elapsed(&self, instant: Self::Instant) -> Duration;
fn duration_between(
        &self,
        earlier: Self::Instant,
        later: Self::Instant
    ) -> Duration;
fn sleep(&self, duration: Duration) -> Self::Sleep; }
Expand description

Trait for async runtime functionality needed by turbulence.

This is designed so that it can be implemented on multiple platforms with multiple runtimes, including wasm32-unknown-unknown, where std::time::Instant is unavailable.

Associated Types

Required methods

This is similar to the futures::task::Spawn trait, but it is generic in the spawned future, which is better for backends like tokio.

Return the current instant.

Return the time elapsed since the given instant.

Similarly to std::time::Instant::duration_since, may panic if later comes before earlier.

Create a future which resolves after the given time has passed.

Implementations on Foreign Types

Implementors