Expand description
Provides means to implement a typical Pub/Sub mechanism.
This module provides a type Hub
which can be used both to subscribe,
and to send the broadcast messages.
The Hub
type is parametrized by two other types:
Message
— the type of a message that shall be delivered to the subscribers;Registry
— implementation of the subscription/dispatch logic.
A Registry is implemented by defining the following traits:
As a result of subscription Hub::subscribe
method returns an instance of
Receiver<Message,Registry>
. That can be used as a Stream
to receive the messages.
Upon drop the Receiver<Message, Registry>
shall unregister itself from the Hub
.
Structs§
- A subscription hub.
- The receiving side of the subscription.
Traits§
- Dispatch a message of type
M
. - Subscribe using a key of type
K
- Unsubscribe: unregisters a previously created subscription.