Embassy
embassy-executor

Crates

git

Versions

std

Flavors

pub struct SpawnToken<S> { /* private fields */ }
Expand description

Token to spawn a newly-created task in an executor.

When calling a task function (like #[embassy_executor::task] async fn my_task() { ... }), the returned value is a SpawnToken that represents an instance of the task, ready to spawn. You must then spawn it into an executor, typically with Spawner::spawn().

The generic parameter S determines whether the task can be spawned in executors in other threads or not. If S: Send, it can, which allows spawning it into a SendSpawner. If not, it can’t, so it can only be spawned into the current thread’s executor, with Spawner.

Panics

Dropping a SpawnToken instance panics. You may not “abort” spawning a task in this way. Once you’ve invoked a task function and obtained a SpawnToken, you must spawn it.

Trait Implementations

Executes the destructor for this type. 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 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.