Trait EventEmitter

Source
pub trait EventEmitter<T: Clone + Send + Sync + 'static = ()>:
    Send
    + Sync
    + 'static {
    // Required methods
    fn emit(&self, event_arg: T) -> Result<()>;
    fn clone(&self) -> Box<dyn EventEmitter<T>>;
}

Required Methods§

Source

fn emit(&self, event_arg: T) -> Result<()>

Emits an event of type T to all registered listeners for the specified event kind.

§Arguments
  • event_arg: The event data of type T to be emitted.
§Returns
  • Ok(()) if the event was successfully emitted to all listeners.
  • Err(anyhow::Error) if access to the underlying data structure fails, or if no listeners are found for the event kind.
Source

fn clone(&self) -> Box<dyn EventEmitter<T>>

Returns the event emitter.

§Returns
  • A cloned instance of the event emitter.

Implementors§