pub struct Spawner { /* private fields */ }
Expand description

Handle to spawn tasks into an executor.

This Spawner can spawn any task (Send and non-Send ones), but it can only be used in the executor thread (it is not Send itself).

If you want to spawn tasks from another thread, use SendSpawner.

Implementations

Get a Spawner for the current executor.

This function is async just to get access to the current async context. It returns instantly, it does not block/yield.

Panics

Panics if the current executor is not an Embassy executor.

Spawn a task into an executor.

You obtain the token by calling a task function (i.e. one marked with #[embassy_executor::task]).

Spawn a task into an executor, panicking on failure.

Panics

Panics if the spawning fails.

Convert this Spawner to a SendSpawner. This allows you to send the spawner to other threads, but the spawner loses the ability to spawn non-Send tasks.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.