Skip to main content

Runtime

Trait Runtime 

Source
pub trait Runtime:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn sleep(duration: Duration) -> Pin<Box<dyn Future<Output = ()> + Send>>;
    fn interval(period: Duration) -> Pin<Box<dyn Stream<Item = ()> + Send>>;
    fn spawn<F>(future: F)
       where F: Future<Output = ()> + Send + 'static;
}
Expand description

Runtime abstraction for async operations that need executor-specific features.

Most stream operations are runtime-agnostic and use only futures primitives. This trait is needed only for:

  • Time-based operations (delay, debounce, throttle)
  • Spawning background tasks (multicasting, eager evaluation)

Required Methods§

Source

fn sleep(duration: Duration) -> Pin<Box<dyn Future<Output = ()> + Send>>

Sleep for the given duration

Source

fn interval(period: Duration) -> Pin<Box<dyn Stream<Item = ()> + Send>>

Create an interval that yields at regular intervals

Source

fn spawn<F>(future: F)
where F: Future<Output = ()> + Send + 'static,

Spawn a future as a background task

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.

Implementors§