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§
Sourcefn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError>
fn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError>
Spawns a task that polls the given future with output () to completion.
Sourcefn spawn_with_handle<Fut>(
&self,
future: Fut,
) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>
fn spawn_with_handle<Fut>( &self, future: Fut, ) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>
Spawns a task that polls the given future to completion and returns a future that resolves to the spawned future’s output.
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.