SpawnExt

Trait SpawnExt 

Source
pub trait SpawnExt: Spawn {
    // Provided methods
    fn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError>
       where Fut: Future<Output = ()> + Send + 'static { ... }
    fn spawn_with_handle<Fut>(
        &self,
        future: Fut,
    ) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>
       where Fut: Future + Send + 'static,
             <Fut as Future>::Output: Send { ... }
}
Expand description

Extension trait for Spawn.

This is very similar to, and preferred over, futures::task::SpawnExt. Unlike futures::task::SpawnExt, it is compatible with tokio-console, and preserves span information for tracing.

Provided Methods§

Source

fn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError>
where Fut: Future<Output = ()> + Send + 'static,

Spawns a task that polls the given future with output () to completion.

See futures::task::SpawnExt::spawn.

Source

fn spawn_with_handle<Fut>( &self, future: Fut, ) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>
where Fut: Future + Send + 'static, <Fut as Future>::Output: Send,

Spawns a task that polls the given future to completion and returns a future that resolves to the spawned future’s output.

See futures::task::SpawnExt::spawn_with_handle.

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§

Source§

impl<T: Spawn> SpawnExt for T