TopicFilterMap

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>

pub const fn new() -> Self

Creates a new, empty router.

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)>

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>

Returns a reference to the value for the given topic filter.

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>

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

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>

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

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

Returns a mutable iterator over the values matching the given topic.

Trait Implementations§

§

impl<V: Debug> Debug for TopicFilterMap<V>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<V> Freeze for TopicFilterMap<V>

§

impl<V> RefUnwindSafe for TopicFilterMap<V>
where V: RefUnwindSafe,

§

impl<V> Send for TopicFilterMap<V>
where V: Send,

§

impl<V> Sync for TopicFilterMap<V>
where V: Sync,

§

impl<V> Unpin for TopicFilterMap<V>

§

impl<V> UnwindSafe for TopicFilterMap<V>
where V: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more