pub trait Handler<I, O>: Send + Sync{
// 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§
Sourcefn 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,
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".