Skip to main content

Spawner

Trait Spawner 

Source
pub trait Spawner {
    // Required method
    fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>);
}
Expand description

A spawner trait for executing futures on an async runtime.

This abstraction allows you to use whatever concurrency model you want (tokio, async-std, embassy, etc.).

Function pointers and closures automatically implement this trait via the blanket implementation.

Required Methods§

Source

fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>)

Spawn a future on the async runtime.

Implementors§

Source§

impl<F> Spawner for F
where F: Fn(Pin<Box<dyn Future<Output = ()> + Send>>),

Implement Spawner for any callable type that matches the signature.

This includes function pointers, closures, and function items.