Struct paho_mqtt::topic_matcher::TopicMatcher
source · [−]pub struct TopicMatcher<T: Default> { /* private fields */ }
Expand description
A collection of topic filters to arbitrary objects.
This can be used to get an iterator to all items that have a filter that
matches a topic. To test against a single filter, see
TopicFilter
. This collection is more commonly used
when there are a nuber of filters and each needs to be associated with a
particular action or piece of data. Note, though, that a single incoming
topic could match against several items in the collection. For example,
the topic:
data/temperature/engine
Could match against the filters: data/temperature/# data/+/engine
Thus, the collection gives an iterator for the items matching a topic.
A common use for this would be to store callbacks to proces incoming messages based on topics.
This code was adapted from the Eclipse Python MQTTMatcher
class:
https://github.com/eclipse/paho.mqtt.python/blob/master/src/paho/mqtt/matcher.py
which use a prefix tree (trie) to store the values.
Implementations
sourceimpl<T: Default> TopicMatcher<T>
impl<T: Default> TopicMatcher<T>
sourcepub fn get(&self, key: &str) -> Option<&T>
pub fn get(&self, key: &str) -> Option<&T>
Gets a value from the collection using an exact filter match.
Trait Implementations
sourceimpl<T: Default + Default> Default for TopicMatcher<T>
impl<T: Default + Default> Default for TopicMatcher<T>
sourcefn default() -> TopicMatcher<T>
fn default() -> TopicMatcher<T>
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for TopicMatcher<T> where
T: RefUnwindSafe,
impl<T> Send for TopicMatcher<T> where
T: Send,
impl<T> Sync for TopicMatcher<T> where
T: Sync,
impl<T> Unpin for TopicMatcher<T> where
T: Unpin,
impl<T> UnwindSafe for TopicMatcher<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more