Trait SpawnHandle

Source
pub trait SpawnHandle:
    Clone
    + Send
    + 'static {
    // Required methods
    fn spawn(
        &self,
        name: &'static str,
        task: impl Future<Output = ()> + Send + 'static,
    );
    fn spawn_essential(
        &self,
        name: &'static str,
        task: impl Future<Output = ()> + Send + 'static,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send>>;
}
Expand description

An abstraction for an execution engine for Rust’s asynchronous tasks.

Required Methods§

Source

fn spawn( &self, name: &'static str, task: impl Future<Output = ()> + Send + 'static, )

Run a new task.

Source

fn spawn_essential( &self, name: &'static str, task: impl Future<Output = ()> + Send + 'static, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send>>

Run a new task and returns a handle to it. If there is some error or panic during execution of the task, the handle should return an error.

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§