Struct SubscriberManager
pub struct SubscriberManager {
subscribed: HashMap<String, Subscriber>,
unsubscribed: HashSet<String>,
close_tx: Option<Sender<()>>,
channel_capacity: usize,
}Fields§
§subscribed: HashMap<String, Subscriber>§unsubscribed: HashSet<String>§close_tx: Option<Sender<()>>§channel_capacity: usizeImplementations§
§impl SubscriberManager
impl SubscriberManager
pub(crate) fn new(capacity: usize) -> Self
pub(crate) fn new(capacity: usize) -> Self
Creates a new SubscriberManager instance with the provided
capacity. The capacity parameter sets the capacity of the
broadcast channels used to distribute messages to subscribers. If
capacity is 0, it is set to 1. If capacity is between 0 and
usize::MAX / 2, it is used as is. If capacity is between
usize::MAX / 2 + 1 and usize::MAX, it is set to usize::MAX / 2.
pub(crate) fn with_close_tx(close_tx: Sender<()>, capacity: usize) -> Self
pub(crate) fn with_close_tx(close_tx: Sender<()>, capacity: usize) -> Self
Creates a new SubscriberManager instance with the provided close_tx
and capacity. The close_tx parameter is a channel sender that
can be used to signal the manager to close. The capacity parameter
sets the capacity of the broadcast channels used to distribute
messages to subscribers. If capacity is 0, it is set to 1. If
capacity is between 0 and usize::MAX / 2, it is used as is. If
capacity is between usize::MAX / 2 + 1 and usize::MAX, it is
set to usize::MAX / 2.
pub(crate) fn sender(&self, topic: &str) -> Option<&Sender<Result<Publish>>>
pub(crate) fn sender(&self, topic: &str) -> Option<&Sender<Result<Publish>>>
Returns a reference to the Sender for the given topic, if the
topic is currently subscribed.
pub(crate) fn receiver(&self, topic: &str) -> Option<Receiver<Result<Publish>>>
pub(crate) fn receiver(&self, topic: &str) -> Option<Receiver<Result<Publish>>>
Returns a receiver for the given topic, if the topic is currently subscribed
pub(crate) fn qos(&self, topic: &str) -> Option<QoS>
pub(crate) fn qos(&self, topic: &str) -> Option<QoS>
Returns the Quality of Service (QoS) level for the given topic, if
the topic is currently subscribed.
pub(crate) fn subscribed_diff<Iter>(&self, topics: Iter) -> Vec<String>
pub(crate) fn subscribed_diff<Iter>(&self, topics: Iter) -> Vec<String>
Returns an iterator over the topics that are not currently subscribed.
pub(crate) fn subscribe( &mut self, topic: &str, qos: QoS, ) -> Receiver<Result<Publish>>
pub(crate) fn subscribe_many<Iter>( &mut self, topics: Iter, qos: QoS, ) -> Vec<Receiver<Result<Publish>>>
pub(crate) fn unsubscribe(&mut self, topic: &str)
pub(crate) fn unsubscribe(&mut self, topic: &str)
Removes the given topic from the list of subscribed topics and the list of unsubscribed topics.
pub(crate) fn schedule_unsubscribe(&mut self, topic: &str)
pub(crate) fn schedule_unsubscribe(&mut self, topic: &str)
Schedules the unsubscription of the given topic.
pub(crate) fn schedule_unsubscribe_many<Iter>(&mut self, topics: Iter)
pub(crate) fn schedule_unsubscribe_many<Iter>(&mut self, topics: Iter)
Schedules the unsubscription of the given topics.
pub(crate) const fn scheduled(&self) -> &HashSet<String>
pub(crate) const fn scheduled(&self) -> &HashSet<String>
Returns a reference to the set of topics that have been scheduled for unsubscription.
pub(crate) fn subscribers(
&self,
) -> impl Iterator<Item = &Sender<Result<Publish>>>
pub(crate) fn subscribers( &self, ) -> impl Iterator<Item = &Sender<Result<Publish>>>
Returns an iterator over the senders that have subscribed to this manager.
pub(crate) fn topics_with_qos(&self) -> impl Iterator<Item = (&str, QoS)>
pub(crate) fn topics_with_qos(&self) -> impl Iterator<Item = (&str, QoS)>
Returns an iterator over the topics that have been subscribed to, along
with their associated QoS level.