Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<I, O>: Send + Sync
where I: Send + 'static, O: Send + Clone + 'static,
{ // Required method fn handle<'life0, 'async_trait>( &'life0 self, task: I, emit: Sender<Event<O>>, cancel: CancellationToken, ) -> Pin<Box<dyn Future<Output = AppResult<O>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; }
Expand description

Core trait for worker task handlers.

Implementors receive a task I, an event sender for streaming intermediate results, and a cancellation token for cooperative cancellation.

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, task: I, emit: Sender<Event<O>>, cancel: CancellationToken, ) -> Pin<Box<dyn Future<Output = AppResult<O>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the task, emitting intermediate events via emit and honouring cancellation requests via cancel.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§