Struct RawMqttClient

Source
pub struct RawMqttClient<'a, T, const MAX_PROPERTIES: usize, R: RngCore>
where T: Read + Write,
{ /* private fields */ }

Implementations§

Source§

impl<'a, T, const MAX_PROPERTIES: usize, R> RawMqttClient<'a, T, MAX_PROPERTIES, R>
where T: Read + Write, R: RngCore,

Source

pub fn new( network_driver: T, buffer: &'a mut [u8], buffer_len: usize, recv_buffer: &'a mut [u8], recv_buffer_len: usize, config: ClientConfig<'a, MAX_PROPERTIES, R>, ) -> Self

Source

pub async fn connect_to_broker<'b>(&'b mut self) -> Result<(), ReasonCode>

Method allows client connect to server. Client is connecting to the specified broker in the ClientConfig. Method selects proper implementation of the MQTT version based on the config. If the connection to the broker fails, method returns Err variable that contains Reason codes returned from the broker.

Source

pub async fn disconnect<'b>(&'b mut self) -> Result<(), ReasonCode>

Method allows client disconnect from the server. Client disconnects from the specified broker in the ClientConfig. Method selects proper implementation of the MQTT version based on the config. If the disconnect from the broker fails, method returns Err variable that contains Reason codes returned from the broker.

Source

pub async fn send_message<'b>( &'b mut self, topic_name: &'b str, message: &'b [u8], qos: QualityOfService, retain: bool, ) -> Result<u16, ReasonCode>

Method allows sending message to broker specified from the ClientConfig. Client sends the message from the parameter message to the topic topic_name on the broker specified in the ClientConfig. If the send fails method returns Err with reason code received by broker.

Source

pub async fn subscribe_to_topics<'b, const TOPICS: usize>( &'b mut self, topic_names: &'b Vec<&'b str, TOPICS>, ) -> Result<u16, ReasonCode>

Method allows client subscribe to multiple topics specified in the parameter topic_names on the broker specified in the ClientConfig. Generics TOPICS sets the value of the topics_names vector. MQTT protocol implementation is selected automatically.

Source

pub async fn unsubscribe_from_topic<'b>( &'b mut self, topic_name: &'b str, ) -> Result<u16, ReasonCode>

Method allows client unsubscribe from the topic specified in the parameter topic_name on the broker from the ClientConfig. MQTT protocol implementation is selected automatically.

Source

pub async fn send_ping<'b>(&'b mut self) -> Result<(), ReasonCode>

Method allows client send PING message to the broker specified in the ClientConfig. If there is expectation for long running connection. Method should be executed regularly by the timer that counts down the session expiry interval.

Source

pub async fn poll<'b, const MAX_TOPICS: usize>( &'b mut self, ) -> Result<Event<'b>, ReasonCode>

Auto Trait Implementations§

§

impl<'a, T, const MAX_PROPERTIES: usize, R> Freeze for RawMqttClient<'a, T, MAX_PROPERTIES, R>
where R: Freeze, T: Freeze,

§

impl<'a, T, const MAX_PROPERTIES: usize, R> RefUnwindSafe for RawMqttClient<'a, T, MAX_PROPERTIES, R>

§

impl<'a, T, const MAX_PROPERTIES: usize, R> Send for RawMqttClient<'a, T, MAX_PROPERTIES, R>
where R: Send, T: Send,

§

impl<'a, T, const MAX_PROPERTIES: usize, R> Sync for RawMqttClient<'a, T, MAX_PROPERTIES, R>
where R: Sync, T: Sync,

§

impl<'a, T, const MAX_PROPERTIES: usize, R> Unpin for RawMqttClient<'a, T, MAX_PROPERTIES, R>
where R: Unpin, T: Unpin,

§

impl<'a, T, const MAX_PROPERTIES: usize, R> !UnwindSafe for RawMqttClient<'a, T, MAX_PROPERTIES, R>

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.