MqttClient

Struct MqttClient 

Source
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,

Source

pub fn new(transport: T, options: MqttOptions<'a>) -> Self

Source

pub async fn connect(&mut self) -> Result<(), MqttError<T::Error>>

Attempts to connect to the MQTT broker.

Source

pub async fn publish<'p>( &mut self, _topic: &'p str, _payload: &'p [u8], _qos: QoS, ) -> Result<(), MqttError<T::Error>>

Publishes a message to a topic.

Source

pub async fn poll<'p>( &'p mut self, ) -> Result<Option<MqttEvent<'p>>, MqttError<T::Error>>

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

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.