Skip to main content

AsyncExecutor

Trait AsyncExecutor 

Source
pub trait AsyncExecutor:
    Clone
    + Send
    + Sync {
    // Required methods
    fn new() -> Self;
    fn spawn<F: Future<Output = ()> + Send + 'static>(&self, future: F);
    fn block_on<F: Future<Output = ()>>(&self, future: F);
}
Expand description

Runtime-agnostic async task executor trait.

Required Methods§

Source

fn new() -> Self

Create a new executor instance.

Source

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

Spawn a fire-and-forget future onto the runtime.

Source

fn block_on<F: Future<Output = ()>>(&self, future: F)

Drive a future to completion on the current thread.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl AsyncExecutor for TokioExecutor

Available on crate feature tokio only.