pub trait EventSink<EVT: Send + Sync + 'static>: Send + Sync {
type Error;
// Required methods
fn on_event_owned<'life0, 'async_trait>(
&'life0 self,
event: EVT,
source: Option<Arc<EventBox>>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_event_ref<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 EVT,
source: Option<Arc<EventBox>>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Standartized interface for object reacting to events of specific type. The trait have two methods: on_event_owned which accepts
event object and on_event_ref, accepting borrowed reference to event. It’s supposed that both bethods should work identically.
But sometimes if it is necessary to retranslate the event received. So it is effective to handle owned event case separately from borrowed.
See also crate::EventSinkExt trait which allows to implement only one event handler by using std::borrow::Cow