Struct TopicFilterMap
pub struct TopicFilterMap<V> {
static_routes: BTreeMap<TopicFilter<Box<str>>, V>,
wildcard_routes: BTreeMap<TopicFilter<Box<str>>, V>,
}Expand description
A map of topic filters to values, supporting MQTT wildcards.
Fields§
§static_routes: BTreeMap<TopicFilter<Box<str>>, V>Static topic filters (without wildcards).
wildcard_routes: BTreeMap<TopicFilter<Box<str>>, V>Wildcard topic filters (containing ‘+’ or ‘#’).
Implementations§
§impl<V> TopicFilterMap<V>
impl<V> TopicFilterMap<V>
pub const fn new() -> Self
pub const fn new() -> Self
Creates a new, empty router.
pub fn iter(&self) -> impl Iterator<Item = (&TopicFilter<str>, &V)>
pub fn iter(&self) -> impl Iterator<Item = (&TopicFilter<str>, &V)>
Returns an iterator over all topic filters and their associated values.
Note: The order of iteration is not guaranteed.
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&TopicFilter<str>, &mut V)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&TopicFilter<str>, &mut V)>
Returns a mutable iterator over all topic filters and their associated values.
Note: The order of iteration is not guaranteed.
pub fn get(&self, topic_filter: &TopicFilter<str>) -> Option<&V>
pub fn get(&self, topic_filter: &TopicFilter<str>) -> Option<&V>
Returns a reference to the value for the given topic filter.
pub fn get_mut(&mut self, topic_filter: &TopicFilter<str>) -> Option<&mut V>
pub fn get_mut(&mut self, topic_filter: &TopicFilter<str>) -> Option<&mut V>
Returns a mutable reference to the value for the given topic filter.
pub fn insert(
&mut self,
topic_filter: TopicFilter<Box<str>>,
value: V,
) -> Option<V>
pub fn insert( &mut self, topic_filter: TopicFilter<Box<str>>, value: V, ) -> Option<V>
Inserts a value for the given topic filter, returning the previous value if it existed.
pub fn get_or_insert_with(
&mut self,
topic_filter: &TopicFilter<str>,
f: impl FnOnce() -> V,
) -> &mut V
pub fn get_or_insert_with( &mut self, topic_filter: &TopicFilter<str>, f: impl FnOnce() -> V, ) -> &mut V
Returns a mutable reference to the value for the given topic filter, inserting a new value if it does not exist.
pub fn remove(&mut self, topic_filter: &TopicFilter<str>) -> Option<V>
pub fn remove(&mut self, topic_filter: &TopicFilter<str>) -> Option<V>
Removes the value for the given topic filter.
pub fn get_matches<'a>(
&'a self,
topic: &'a str,
) -> impl Iterator<Item = (&'a TopicFilter<str>, &'a V)> + 'a
pub fn get_matches<'a>( &'a self, topic: &'a str, ) -> impl Iterator<Item = (&'a TopicFilter<str>, &'a V)> + 'a
Returns an iterator over the values matching the given topic.
pub fn get_matches_mut<'a>(
&'a mut self,
topic: &'a str,
) -> impl Iterator<Item = (&'a TopicFilter<str>, &'a mut V)> + 'a
pub fn get_matches_mut<'a>( &'a mut self, topic: &'a str, ) -> impl Iterator<Item = (&'a TopicFilter<str>, &'a mut V)> + 'a
Returns a mutable iterator over the values matching the given topic.