EventConsumer

Trait EventConsumer 

Source
pub trait EventConsumer<E: Event>:
    Send
    + Sync
    + 'static {
    type Error: Error + Send + Sync + Sized + 'static;

    // Required methods
    fn accept<'life0, 'async_trait>(
        &'life0 self,
        event: E,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn accept_sync(&self, event: E) -> Result<(), Self::Error>;
}
Expand description

The inbox side of an Actor

Required Associated Types§

Source

type Error: Error + Send + Sync + Sized + 'static

The error type for this event consumer

Required Methods§

Source

fn accept<'life0, 'async_trait>( &'life0 self, event: E, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Accepts an event

This method can run long running computation, but is strongly encouraged to properly utilize the blocking thread pool.

§Errors

Will return an error if communication with the actor fails

Source

fn accept_sync(&self, event: E) -> Result<(), Self::Error>

Accepts an event, blocking if needed

§Errors

Will return an error if communication with the actor fails

Implementations on Foreign Types§

Source§

impl<E: Event> EventConsumer<E> for Sender<E>

Source§

type Error = SendError<E>

Source§

fn accept<'life0, 'async_trait>( &'life0 self, event: E, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn accept_sync(&self, event: E) -> Result<(), Self::Error>

Source§

impl<E: Event, F, H> EventConsumer<E> for (F, H)
where F: Fn(&E::Flags, &E) -> bool + Send + Sync + 'static, H: Fn(E) + Send + Sync + 'static,

Source§

type Error = Infallible

Source§

fn accept<'life0, 'async_trait>( &'life0 self, event: E, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn accept_sync(&self, event: E) -> Result<(), Self::Error>

Implementors§