Skip to main content

EventHandler

Trait EventHandler 

Source
pub trait EventHandler: Send + Sync {
    // Required methods
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        event: EventData,
    ) -> Pin<Box<dyn Future<Output = WaeResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn event_types(&self) -> Vec<EventTypeName> ;
}
Expand description

事件处理器 trait (异步)

定义异步事件处理器的接口。

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, event: EventData, ) -> Pin<Box<dyn Future<Output = WaeResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

处理事件

Source

fn event_types(&self) -> Vec<EventTypeName>

获取处理器感兴趣的事件类型

Implementors§

Source§

impl<F> EventHandler for AsyncEventHandler<F>
where F: Fn(EventData) -> Pin<Box<dyn Future<Output = WaeResult<()>> + Send + Sync>> + Send + Sync + 'static,