Skip to main content

LocalSpawner

Trait LocalSpawner 

Source
pub trait LocalSpawner {
    // Required method
    fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
       where F: Future<Output = ()> + 'static;
}
Expand description

Runs a task that is not Send in the background, on a single-threaded executor.

Use it with the *_local_on methods of Deferred. The same requirements as Spawner apply.

§Embassy

Use embassy_spawner! to declare a LocalSpawner for embassy.

Required Methods§

Source

fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
where F: Future<Output = ()> + 'static,

Runs task in the background.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl LocalSpawner for LocalSet

Available on crate feature tokio only.

Spawns on this LocalSet. The task only makes progress while the LocalSet is run.

Source§

fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
where F: Future<Output = ()> + 'static,

Source§

impl<'a> LocalSpawner for LocalExecutor<'a>

Available on crate feature smol only.

Spawns on this smol local executor. The task only makes progress while the executor is run.

Source§

fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
where F: Future<Output = ()> + 'static,

Source§

impl<S: LocalSpawner + ?Sized> LocalSpawner for &S

Source§

fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
where F: Future<Output = ()> + 'static,

Source§

impl<S: LocalSpawner + ?Sized> LocalSpawner for &mut S

Source§

fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
where F: Future<Output = ()> + 'static,

Source§

impl<S: LocalSpawner + ?Sized> LocalSpawner for Arc<S>

Available on target_has_atomic=ptr and crate feature alloc only.
Source§

fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
where F: Future<Output = ()> + 'static,

Source§

impl<S: LocalSpawner + ?Sized> LocalSpawner for Box<S>

Available on crate feature alloc only.
Source§

fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
where F: Future<Output = ()> + 'static,

Source§

impl<S: LocalSpawner + ?Sized> LocalSpawner for Rc<S>

Available on crate feature alloc only.
Source§

fn spawn_local<F>(&self, task: F) -> Result<(), SpawnError>
where F: Future<Output = ()> + 'static,

Implementors§