pub trait SubjectActor<Event>: Actor{
// Required method
fn observers_mut(&mut self) -> &mut ObserverSet<Event>;
// Provided methods
fn register_observer(&mut self, observer: Recipient<Event>) { ... }
fn unregister_observer(&mut self, observer: Recipient<Event>) { ... }
fn notify_observers(
&mut self,
event: Event,
) -> impl Future<Output = ()> + Send { ... }
fn try_notify_observers(&mut self, event: Event) { ... }
}Available on crate feature
observer only.Expand description
Describes the behavior of an actor which works as a subject of the given event type.
An actor could be the subject of multiple event types, just implement this trait multiple times.
Required Methods§
Sourcefn observers_mut(&mut self) -> &mut ObserverSet<Event>
fn observers_mut(&mut self) -> &mut ObserverSet<Event>
Returns a mutable reference to the set of observers for this event type.
Provided Methods§
Sourcefn register_observer(&mut self, observer: Recipient<Event>)
fn register_observer(&mut self, observer: Recipient<Event>)
Registers an observer.
Sourcefn unregister_observer(&mut self, observer: Recipient<Event>)
fn unregister_observer(&mut self, observer: Recipient<Event>)
Unregisters an observer.
Sourcefn notify_observers(&mut self, event: Event) -> impl Future<Output = ()> + Send
fn notify_observers(&mut self, event: Event) -> impl Future<Output = ()> + Send
Notifies all observers.
This method will wait until there is capacity in the mailbox of the observer.
Sourcefn try_notify_observers(&mut self, event: Event)
fn try_notify_observers(&mut self, event: Event)
Notifies all observers.
This method will return immediately if there is no capacity in the mailbox of the observer.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".