pub trait EventHandler:
Send
+ Sync
+ 'static {
// Required method
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
events: &'life1 [Box<dyn Event>],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
EventHandler trait defines the interface for how to handle the event.
Required Methods§
Sourcefn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
events: &'life1 [Box<dyn Event>],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
events: &'life1 [Box<dyn Event>],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Processes and handles incoming events. The [DefaultEventHandlerImpl] implementation forwards events to frontend instances for persistence.
We use &[Box<dyn Event>]
to avoid consuming the events, so the caller can buffer the events and retry if the handler fails.