Skip to main content

Execute

Trait Execute 

pub trait Execute:
    Send
    + Sync
    + 'static {
    // Required method
    fn execute(&self, f: Pin<Box<dyn Future<Output = ()> + Send>>);

    // Provided methods
    fn try_execute(
        &self,
        f: Pin<Box<dyn Future<Output = ()> + Send>>,
    ) -> Result<(), Error> { ... }
    fn timeout(&self) -> Option<Pin<Box<dyn Future<Output = ()> + Send>>> { ... }
    fn sleep(
        &self,
        _duration: Duration,
    ) -> Option<Pin<Box<dyn Future<Output = ()> + Send>>> { ... }
}
Expand description

Executes background tasks and optionally provides timers.

Required Methods§

fn execute(&self, f: Pin<Box<dyn Future<Output = ()> + Send>>)

Execute an async task in the background.

The executor must keep polling accepted tasks until they complete.

Provided Methods§

fn try_execute( &self, f: Pin<Box<dyn Future<Output = ()> + Send>>, ) -> Result<(), Error>

Submit an async task, returning an error if the executor rejects it. An executor that returns an error must leave the task unpolled.

The default implementation forwards to Self::execute. Executors with fallible submission should override this method.

fn timeout(&self) -> Option<Pin<Box<dyn Future<Output = ()> + Send>>>

Return the configured timeout for an individual I/O task, if any.

fn sleep( &self, _duration: Duration, ) -> Option<Pin<Box<dyn Future<Output = ()> + Send>>>

Return a future that completes after duration, if timers are supported.

The timer must make progress independently of the executor’s task queue.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl Execute for ()

§

fn execute(&self, _: Pin<Box<dyn Future<Output = ()> + Send>>)

§

fn try_execute( &self, _: Pin<Box<dyn Future<Output = ()> + Send>>, ) -> Result<(), Error>

Implementors§