Trait LocalExecutor

Source
pub trait LocalExecutor {
    // Required method
    fn spawn<T: 'static>(
        &self,
        fut: impl Future<Output = T> + 'static,
    ) -> impl LocalTask<Output = T>;
}
Expand description

A trait for executor implementations that can spawn futures on the current thread.

This trait represents executors that operate within a single thread context, allowing them to work with futures that are not Send. This is essential for working with non-thread-safe types like Rc, RefCell, or thread-local storage.

Required Methods§

Source

fn spawn<T: 'static>( &self, fut: impl Future<Output = T> + 'static, ) -> impl LocalTask<Output = T>

Spawns a future on this local executor.

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.

Implementations on Foreign Types§

Source§

impl LocalExecutor for LocalExecutor<'static>

Source§

fn spawn<T: 'static>( &self, fut: impl Future<Output = T> + 'static, ) -> impl LocalTask<Output = T>

Implementors§