MessageBroker

Trait MessageBroker 

Source
pub trait MessageBroker: AsMessageBroker {
    // Required method
    fn get_message_topic(&self, msg_type_id: MessageTypeId) -> Arc<MessageTopic>;

    // Provided methods
    fn register_subscription(
        self: Arc<Self>,
        sub: &mut dyn ErasedSubscription,
    ) -> Result<(), MessageBrokerError> { ... }
    fn unregister_subscription(
        &self,
        sub: &mut dyn ErasedSubscription,
    ) -> Result<(), MessageBrokerError> { ... }
    fn publish_message(
        &self,
        msg: Arc<dyn Message>,
    ) -> Result<(), MessageBrokerError> { ... }
}
Expand description

A type which delivers messages from publishers to subscribers.

Required Methods§

Source

fn get_message_topic(&self, msg_type_id: MessageTypeId) -> Arc<MessageTopic>

Gets MessageTopic which is responsible for handling messages of the given type.

Provided Methods§

Source

fn register_subscription( self: Arc<Self>, sub: &mut dyn ErasedSubscription, ) -> Result<(), MessageBrokerError>

Registers the subscription in the broker.

After that the subscription can receive messages.

Source

fn unregister_subscription( &self, sub: &mut dyn ErasedSubscription, ) -> Result<(), MessageBrokerError>

Unregisters the subscription in the broker.

After that the subscription stops receiving messages.

Source

fn publish_message( &self, msg: Arc<dyn Message>, ) -> Result<(), MessageBrokerError>

Sends the given message to all subscribers which are listening for messages of its type.

Implementors§