Skip to main content

EventSource

Trait EventSource 

Source
pub trait EventSource: Send + Sync {
    // Required methods
    fn start<'life0, 'async_trait>(
        &'life0 self,
        sender: Sender<Event>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stop<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn name(&self) -> &str;
}
Expand description

Trait for event sources

An event source generates events from external signals and sends them through the provided channel. Sources run asynchronously and can be stopped gracefully.

Required Methods§

Source

fn start<'life0, 'async_trait>( &'life0 self, sender: Sender<Event>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start the source, emitting events through the sender

This method runs until stop() is called or the sender is dropped. Implementations should handle errors gracefully (log and continue).

Source

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

Signal the source to stop

Source

fn name(&self) -> &str

Human-readable source name

Implementors§