pub struct MqttClient<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize>where
T: MqttTransport,{ /* private fields */ }
Expand description
The asynchronous MQTT client.
Implementations§
Source§impl<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize> MqttClient<'a, T, MAX_TOPICS, BUF_SIZE>where
T: MqttTransport,
impl<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize> MqttClient<'a, T, MAX_TOPICS, BUF_SIZE>where
T: MqttTransport,
pub fn new(transport: T, options: MqttOptions<'a>) -> Self
Sourcepub async fn connect(&mut self) -> Result<(), MqttError<T::Error>>where
T::Error: TransportError,
pub async fn connect(&mut self) -> Result<(), MqttError<T::Error>>where
T::Error: TransportError,
Attempts to connect to the MQTT broker.
Sourcepub async fn publish<'p>(
&mut self,
_topic: &'p str,
_payload: &'p [u8],
_qos: QoS,
) -> Result<(), MqttError<T::Error>>where
T::Error: TransportError,
pub async fn publish<'p>(
&mut self,
_topic: &'p str,
_payload: &'p [u8],
_qos: QoS,
) -> Result<(), MqttError<T::Error>>where
T::Error: TransportError,
Publishes a message to a topic.
Sourcepub async fn poll<'p>(
&'p mut self,
) -> Result<Option<MqttEvent<'p>>, MqttError<T::Error>>where
T::Error: TransportError,
pub async fn poll<'p>(
&'p mut self,
) -> Result<Option<MqttEvent<'p>>, MqttError<T::Error>>where
T::Error: TransportError,
Polls the connection for incoming packets and handles keep-alives.
The returned MqttEvent
contains references to the client’s internal receive
buffer. These references are only valid until the next call to poll
.
Auto Trait Implementations§
impl<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize> Freeze for MqttClient<'a, T, MAX_TOPICS, BUF_SIZE>where
T: Freeze,
impl<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize> RefUnwindSafe for MqttClient<'a, T, MAX_TOPICS, BUF_SIZE>where
T: RefUnwindSafe,
impl<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize> Send for MqttClient<'a, T, MAX_TOPICS, BUF_SIZE>where
T: Send,
impl<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize> Sync for MqttClient<'a, T, MAX_TOPICS, BUF_SIZE>where
T: Sync,
impl<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize> Unpin for MqttClient<'a, T, MAX_TOPICS, BUF_SIZE>where
T: Unpin,
impl<'a, T, const MAX_TOPICS: usize, const BUF_SIZE: usize> UnwindSafe for MqttClient<'a, T, MAX_TOPICS, BUF_SIZE>where
T: UnwindSafe,
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