embassy_executor

Struct SpawnToken

Source
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.

Implementations§

Source§

impl<S> SpawnToken<S>

Source

pub fn new_failed() -> Self

Return a SpawnToken that represents a failed spawn.

Trait Implementations§

Source§

impl<S> Drop for SpawnToken<S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for SpawnToken<S>

§

impl<S> !RefUnwindSafe for SpawnToken<S>

§

impl<S> !Send for SpawnToken<S>

§

impl<S> !Sync for SpawnToken<S>

§

impl<S> Unpin for SpawnToken<S>

§

impl<S> !UnwindSafe for SpawnToken<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 4 bytes