Trait EventSubscriber

Source
pub trait EventSubscriber {
    // Required methods
    fn process(&self, events: Events, ops: &mut EventOps<'_>);
    fn init(&self, ops: &mut EventOps<'_>);
}
Expand description

Allows the interaction between an EventManager and different event subscribers that do not require a &mut self borrow to perform init and process.

Any type implementing this also trivially implements MutEventSubscriber. The main role of EventSubscriber is to allow wrappers such as Arc and Rc to implement EventSubscriber themselves when the inner type is also an implementor.

Required Methods§

Source

fn process(&self, events: Events, ops: &mut EventOps<'_>)

Process events triggered in the event manager loop.

Optionally, the subscriber can use ops to update the events it monitors.

Source

fn init(&self, ops: &mut EventOps<'_>)

Initialization called by the EventManager when the subscriber is registered.

The subscriber is expected to use ops to register the events it wants to monitor.

Implementations on Foreign Types§

Source§

impl<T: EventSubscriber + ?Sized> EventSubscriber for Box<T>

Source§

fn process(&self, events: Events, ops: &mut EventOps<'_>)

Source§

fn init(&self, ops: &mut EventOps<'_>)

Source§

impl<T: EventSubscriber + ?Sized> EventSubscriber for Rc<T>

Source§

fn process(&self, events: Events, ops: &mut EventOps<'_>)

Source§

fn init(&self, ops: &mut EventOps<'_>)

Source§

impl<T: EventSubscriber + ?Sized> EventSubscriber for Arc<T>

Source§

fn process(&self, events: Events, ops: &mut EventOps<'_>)

Source§

fn init(&self, ops: &mut EventOps<'_>)

Source§

impl<T: MutEventSubscriber + ?Sized> EventSubscriber for RefCell<T>

Source§

fn process(&self, events: Events, ops: &mut EventOps<'_>)

Source§

fn init(&self, ops: &mut EventOps<'_>)

Source§

impl<T: MutEventSubscriber + ?Sized> EventSubscriber for Mutex<T>

Source§

fn process(&self, events: Events, ops: &mut EventOps<'_>)

Source§

fn init(&self, ops: &mut EventOps<'_>)

Implementors§