pub struct MqttTopicManager<'a> { /* private fields */ }
Available on crate features
client
and mqtt
only.Expand description
The MQTT topic manager. Subscribes and unsubscribes from topics.
Implementations§
Source§impl<'a> MqttTopicManager<'a>
impl<'a> MqttTopicManager<'a>
Sourcepub fn with_topic(self, topic: Topic) -> Self
pub fn with_topic(self, topic: Topic) -> Self
Add a new topic to the list.
Sourcepub fn with_topics(self, topics: impl IntoIterator<Item = Topic>) -> Self
pub fn with_topics(self, topics: impl IntoIterator<Item = Topic>) -> Self
Add a collection of topics to the list.
Sourcepub async fn subscribe<C: Fn(&TopicEvent) + Send + Sync + 'static>(
self,
callback: C,
) -> Result<(), Error>
pub async fn subscribe<C: Fn(&TopicEvent) + Send + Sync + 'static>( self, callback: C, ) -> Result<(), Error>
Subscribe to the given topics with the callback.
Sourcepub async fn unsubscribe(self) -> Result<(), Error>
pub async fn unsubscribe(self) -> Result<(), Error>
Unsubscribe from the given topics. If no topics were provided, the function will unsubscribe from every subscribed topic.
Auto Trait Implementations§
impl<'a> Freeze for MqttTopicManager<'a>
impl<'a> !RefUnwindSafe for MqttTopicManager<'a>
impl<'a> Send for MqttTopicManager<'a>
impl<'a> Sync for MqttTopicManager<'a>
impl<'a> Unpin for MqttTopicManager<'a>
impl<'a> !UnwindSafe for MqttTopicManager<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more