Skip to main content

Executor

Trait Executor 

Source
pub trait Executor<Fut> {
    // Required method
    fn execute(&self, fut: Fut);
}
Expand description

An executor of futures.

This trait allows Hyper to abstract over async runtimes. Implement this trait for your own type.

§Example

#[derive(Clone)]
struct TokioExecutor;

impl<F> Executor<F> for TokioExecutor
where
    F: Future + Send + 'static,
    F::Output: Send + 'static,
{
    fn execute(&self, future: F) {
        tokio::spawn(future);
    }
}

Required Methods§

Source

fn execute(&self, fut: Fut)

Place the future into the executor to be run.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<Fut> Executor<Fut> for TokioExecutor
where Fut: Future + Send + 'static, <Fut as Future>::Output: Send + 'static,

Source§

fn execute(&self, fut: Fut)

Implementors§