use futures::Future;
use std::pin::Pin;
/// A handle for waiting the task's completion.
pub type TaskHandle = Pin<Box<dyn Future<Output = Result<(), ()>> + Send>>;
/// An abstraction for an execution engine for Rust's asynchronous tasks.
pub trait SpawnHandle: Clone + Send + 'static {
/// Run a new task.
fn spawn(&self, name: &'static str, task: impl Future<Output = ()> + Send + 'static);
/// Run a new task and returns a handle to it. If there is some error or panic during
/// execution of the task, the handle should return an error.
fn spawn_essential(
&self,
name: &'static str,
task: impl Future<Output = ()> + Send + 'static,
) -> TaskHandle;
}