Skip to main content

EventSubscriber

Trait EventSubscriber 

Source
pub trait EventSubscriber: Send + Sync {
    // Required methods
    fn event_name(&self) -> &'static str;
    fn handle(&self, event: &dyn Event) -> Result<(), EventError>;

    // Provided method
    fn priority(&self) -> i32 { ... }
}
Expand description

Handles events of one name. Higher Self::priority runs first.

Required Methods§

Source

fn event_name(&self) -> &'static str

Event name this subscriber listens to.

Source

fn handle(&self, event: &dyn Event) -> Result<(), EventError>

Handles a matching event.

§Errors

Return EventError when handling fails. Remaining subscribers still run.

Provided Methods§

Source

fn priority(&self) -> i32

Dispatch order. Higher values run first. Default is 0.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§