pub struct MqttClient<'a, M: RawMutex> { /* private fields */ }Expand description
The MQTT Client to publish messages, subscribe, unsubscribe and receive messages
Implementations§
Source§impl<'a, M: RawMutex> MqttClient<'a, M>
impl<'a, M: RawMutex> MqttClient<'a, M>
Sourcepub async fn publish(
&self,
topic: &str,
payload: &[u8],
qos: QoS,
retain: bool,
) -> Result<(), MqttError>
pub async fn publish( &self, topic: &str, payload: &[u8], qos: QoS, retain: bool, ) -> Result<(), MqttError>
Publish a MQTT message with the given parameters
Waits until there is a successful publish result. The publish is successful after all acknolodgements
accordings to the selected QoS have bee exchanged
Sourcepub async fn subscribe(&self, topic: &str) -> Result<(), MqttError>
pub async fn subscribe(&self, topic: &str) -> Result<(), MqttError>
Subscribe to a topic
The method returns after the suback has bee received
Sourcepub async fn unsubscribe(&self, topic: &str) -> Result<(), MqttError>
pub async fn unsubscribe(&self, topic: &str) -> Result<(), MqttError>
unsubscribe from a topic
waits until the unsuback has bee received
Sourcepub async fn receive(&self) -> MqttPublish
pub async fn receive(&self) -> MqttPublish
Waits for the next message
Sourcepub async fn disconnect(&self)
pub async fn disconnect(&self)
send a disconnect packet to the broker
Trait Implementations§
Source§impl<'a, M: Clone + RawMutex> Clone for MqttClient<'a, M>
impl<'a, M: Clone + RawMutex> Clone for MqttClient<'a, M>
Source§fn clone(&self) -> MqttClient<'a, M>
fn clone(&self) -> MqttClient<'a, M>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a, M> Freeze for MqttClient<'a, M>
impl<'a, M> !RefUnwindSafe for MqttClient<'a, M>
impl<'a, M> Send for MqttClient<'a, M>where
M: Sync,
impl<'a, M> Sync for MqttClient<'a, M>where
M: Sync,
impl<'a, M> Unpin for MqttClient<'a, M>
impl<'a, M> !UnwindSafe for MqttClient<'a, M>
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