Task

Trait Task 

Source
pub trait Task<T: 'static> {
    // Required method
    fn handler(&mut self, ctx: T) -> impl Future<Output = ()>;

    // Provided method
    fn start(self) -> TaskHandler<T>
       where Self: Sized + 'static { ... }
}

Required Methods§

Source

fn handler(&mut self, ctx: T) -> impl Future<Output = ()>

Handler need to be implement by user to process a single task.

Be careful: since this handler running inside of a single thread, never blocking it, all IO operations should be spawn out.

Provided Methods§

Source

fn start(self) -> TaskHandler<T>
where Self: Sized + 'static,

Start main handler loop.

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.

Implementors§