Trait iced::executor::Executor

source ·
pub trait Executor: Sized {
    // Required methods
    fn new() -> Result<Self, Error>
       where Self: Sized;
    fn spawn(&self, future: impl Future<Output = ()> + MaybeSend + 'static);

    // Provided method
    fn enter<R>(&self, f: impl FnOnce() -> R) -> R { ... }
}
Expand description

A type that can run futures.

Required Methods§

source

fn new() -> Result<Self, Error>
where Self: Sized,

Creates a new Executor.

source

fn spawn(&self, future: impl Future<Output = ()> + MaybeSend + 'static)

Spawns a future in the Executor.

Provided Methods§

source

fn enter<R>(&self, f: impl FnOnce() -> R) -> R

Runs the given closure inside the Executor.

Some executors, like tokio, require some global state to be in place before creating futures. This method can be leveraged to set up this global state, call a function, restore the state, and obtain the result of the call.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Executor for Runtime

source§

fn new() -> Result<Runtime, Error>

source§

fn spawn(&self, future: impl Future<Output = ()> + Send + 'static)

source§

fn enter<R>(&self, f: impl FnOnce() -> R) -> R

source§

impl Executor for ThreadPool

source§

fn new() -> Result<ThreadPool, Error>

source§

fn spawn(&self, future: impl Future<Output = ()> + Send + 'static)

Implementors§

source§

impl Executor for iced_futures::backend::native::async_std::Executor

source§

impl Executor for iced_futures::backend::native::smol::Executor

source§

impl Executor for iced_futures::backend::null::Executor