pub trait Executor:
Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn spawn(
&self,
f: Pin<Box<dyn Future<Output = ()> + Send>>,
) -> Result<(), ()>;
fn spawn_blocking<F, Res>(&self, f: F) -> JoinHandle<Res> ⓘ
where F: FnOnce() -> Res + Send + 'static,
Res: Send + 'static;
fn interval(&self, duration: Duration) -> Interval;
fn delay(&self, duration: Duration) -> Delay ⓘ;
fn kind(&self) -> ExecutorKind;
}Expand description
Wrapper trait abstracting the Tokio and async-std executors
Required Methods§
Sourcefn spawn(&self, f: Pin<Box<dyn Future<Output = ()> + Send>>) -> Result<(), ()>
fn spawn(&self, f: Pin<Box<dyn Future<Output = ()> + Send>>) -> Result<(), ()>
spawns a new task
Sourcefn spawn_blocking<F, Res>(&self, f: F) -> JoinHandle<Res> ⓘ
fn spawn_blocking<F, Res>(&self, f: F) -> JoinHandle<Res> ⓘ
spawns a new blocking task
Sourcefn interval(&self, duration: Duration) -> Interval
fn interval(&self, duration: Duration) -> Interval
returns a Stream that will produce at regular intervals
Sourcefn kind(&self) -> ExecutorKind
fn kind(&self) -> ExecutorKind
returns which executor is currently used
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.