[][src]Trait revent::Notifiable

pub trait Notifiable {
    fn notify(&mut self, event: &dyn Event, store: &mut EventStore);

    fn take_storage(&mut self) -> EventStore { ... }
fn set_storage(&mut self, _: EventStore) { ... }
fn with_notify(&mut self, mutator: impl FnMut(&mut Self, &mut EventStore)) { ... } }

Main trait of this crate to implement on structures.

Required methods

fn notify(&mut self, event: &dyn Event, store: &mut EventStore)

Notify this structure of an event. It should call Notifiable::notify on all subclasses that are Notifiable.

Loading content...

Provided methods

fn take_storage(&mut self) -> EventStore

Takes event storage from this struct. Used for optimizing away the creation and destruction of the event store. By doing so, we can reuse the same event store for all events.

The default implementation creates a new event store. If you want to speed up your program then you need to take the event store from the struct (via Option::take). Note that you must then also use Notifiable::set_storage to put the store back after it has been used.

fn set_storage(&mut self, _: EventStore)

Return the event store to its place in this struct. See Notifiable::take_storage for more information.

fn with_notify(&mut self, mutator: impl FnMut(&mut Self, &mut EventStore))

Runs code with a given event store and executes all the events at the end of the scope.

Loading content...

Implementors

Loading content...