Trait EventSource

Source
pub trait EventSource {
    // Required method
    fn spawn<F, Fut>(&self, on_event: F) -> JoinHandle<Result<()>>
       where F: Fn(AgentEvent) -> Fut + Send + Sync + 'static,
             Fut: Future<Output = Option<String>> + Send + 'static;
}
Expand description

An event source listens for events, and calls the on_event callback to react to events.

Required Methods§

Source

fn spawn<F, Fut>(&self, on_event: F) -> JoinHandle<Result<()>>
where F: Fn(AgentEvent) -> Fut + Send + Sync + 'static, Fut: Future<Output = Option<String>> + Send + 'static,

The method to run the EventSource.

The run method will be called by Agent in a new thread.

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§