EventEmittingModel

Trait EventEmittingModel 

Source
pub trait EventEmittingModel: BaseModel {
    type Event: Send + Sync + 'static;

    // Required method
    fn get_event_emitter() -> &'static EventEmitter<Self::Event>;

    // Provided methods
    fn register_event_handler<'async_trait, F, Fut>(
        listener: F,
    ) -> Pin<Box<dyn Future<Output = EventHandlerHandle> + Send + 'async_trait>>
       where F: 'async_trait + Fn(State, Arc<Self::Event>) -> Fut + Send + Sync + 'static,
             Fut: 'async_trait + Future<Output = Result<(), Error>> + Send + 'static,
             Self: Send + 'async_trait { ... }
    fn blocking_register_event_handler<F: Fn(State, Arc<Self::Event>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<(), Error>> + Send + 'static>(
        listener: F,
    ) -> EventHandlerHandle { ... }
}

Required Associated Types§

Source

type Event: Send + Sync + 'static

Required Methods§

Provided Methods§

Source

fn register_event_handler<'async_trait, F, Fut>( listener: F, ) -> Pin<Box<dyn Future<Output = EventHandlerHandle> + Send + 'async_trait>>
where F: 'async_trait + Fn(State, Arc<Self::Event>) -> Fut + Send + Sync + 'static, Fut: 'async_trait + Future<Output = Result<(), Error>> + Send + 'static, Self: Send + 'async_trait,

Source

fn blocking_register_event_handler<F: Fn(State, Arc<Self::Event>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<(), Error>> + Send + 'static>( listener: F, ) -> EventHandlerHandle

§Warning

This method will block the current thread if the lock is not available

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§