Trait Subscriber

Source
pub trait Subscriber {
    // Required methods
    fn subscribe(&mut self, msg_broker: Arc<dyn MessageBroker>);
    fn unsubscribe(&mut self);
    fn activate(&self);
    fn deactivate(&self);
    fn process_messages(&mut self);
}
Expand description

A receiver of messages.

Subscriber can receive multiple types of messages by storing multiple Subscriptions.

Required Methods§

Source

fn subscribe(&mut self, msg_broker: Arc<dyn MessageBroker>)

Makes the subscriber listen for messages from the given message broker by registering all its Subscriptions (see ErasedSubscription::register).

Source

fn unsubscribe(&mut self)

Makes the subscriber stop listening for messages from the given message broker by unregistering all its Subscriptions (see ErasedSubscription::unregister).

Source

fn activate(&self)

Makes the subscriber listen for messages by activating all its Subscriptions (see ErasedSubscription::activate) if they were deactivated before.

Source

fn deactivate(&self)

Temporary makes the subscriber not receive any messages by deactivating all its Subscriptions (see ErasedSubscription::deactivate).

Source

fn process_messages(&mut self)

Proccesses all messages received from all Subscriptions of the subscriber.

See Subscription::process_messages

Implementors§