EventSink

Trait EventSink 

Source
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

Required Associated Types§

Required Methods§

Source

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,

Source

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,

Implementations on Foreign Types§

Source§

impl<EVT: Send + Sync + 'static, T: EventSink<EVT> + Send + Sync> EventSink<EVT> for Arc<T>

Source§

type Error = <T as EventSink<EVT>>::Error

Source§

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,

Source§

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,

Source§

impl<EVT: Send + Sync + 'static, T: EventSink<EVT> + Send + Sync> EventSink<EVT> for RwLock<T>

Source§

type Error = <T as EventSink<EVT>>::Error

Source§

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,

Source§

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,

Implementors§