Struct minimq::mqtt_client::MqttClient

source ·
pub struct MqttClient<'buf, TcpStack: TcpClientStack, Clock: Clock, Broker: Broker> { /* private fields */ }
Expand description

The client that can be used for interacting with the MQTT broker.

Implementations§

source§

impl<'buf, TcpStack: TcpClientStack, Clock: Clock, Broker: Broker> MqttClient<'buf, TcpStack, Clock, Broker>

source

pub fn subscribe( &mut self, topics: &[TopicFilter<'_>], properties: &[Property<'_>] ) -> Result<(), Error<TcpStack::Error>>

Subscribe to a topic.

§Note

A subscription is not maintained across a disconnection with the broker. In the case of MQTT disconnections, topics will need to be subscribed to again.

The subscription will not be completed immediately. Call MqttClient::subscriptions_pending() to check for subscriptions being completed.

§Args
  • topics - A list of TopicFilters to subscribe to.
  • properties - A list of properties to attach to the subscription request. May be empty.
source

pub fn subscriptions_pending(&self) -> bool

Check if any subscriptions have not yet been completed.

§Returns

True if any subscriptions are waiting for confirmation from the broker.

source

pub fn is_connected(&mut self) -> bool

Determine if the client has established a connection with the broker.

§Returns

True if the client is connected to the broker.

source

pub fn pending_messages(&self) -> bool

Get the count of messages currently being processed across the connection

§Returns

The number of messages where handshakes have not fully completed. This includes both in-bound messages from the server at QoS::ExactlyOnce and out-bound messages at QoS::AtLeastOnce or QoS::ExactlyOnce.

source

pub fn can_publish(&self, qos: QoS) -> bool

Determine if the client is able to process publish requests.

§Args
  • qos - The QoS level to check publish capabilities of.
§Returns

True if the client is able to publish at the requested QoS.

source

pub fn publish<P: ToPayload>( &mut self, publish: Pub<'_, P> ) -> Result<(), PubError<TcpStack::Error, P::Error>>

Publish a message over MQTT.

§Note

If the client is not yet connected to the broker, the message will be silently ignored.

§Args
  • publish - The publication to generate. See crate::Publication for a builder pattern to generate a message.

Auto Trait Implementations§

§

impl<'buf, TcpStack, Clock, Broker> Freeze for MqttClient<'buf, TcpStack, Clock, Broker>
where Broker: Freeze, TcpStack: Freeze, Clock: Freeze, <TcpStack as TcpClientStack>::TcpSocket: Freeze, <Clock as Clock>::T: Freeze,

§

impl<'buf, TcpStack, Clock, Broker> RefUnwindSafe for MqttClient<'buf, TcpStack, Clock, Broker>
where Broker: RefUnwindSafe, TcpStack: RefUnwindSafe, Clock: RefUnwindSafe, <TcpStack as TcpClientStack>::TcpSocket: RefUnwindSafe, <Clock as Clock>::T: RefUnwindSafe,

§

impl<'buf, TcpStack, Clock, Broker> Send for MqttClient<'buf, TcpStack, Clock, Broker>
where Broker: Send, TcpStack: Send, Clock: Send, <TcpStack as TcpClientStack>::TcpSocket: Send, <Clock as Clock>::T: Send,

§

impl<'buf, TcpStack, Clock, Broker> Sync for MqttClient<'buf, TcpStack, Clock, Broker>
where Broker: Sync, TcpStack: Sync, Clock: Sync, <TcpStack as TcpClientStack>::TcpSocket: Sync, <Clock as Clock>::T: Sync,

§

impl<'buf, TcpStack, Clock, Broker> Unpin for MqttClient<'buf, TcpStack, Clock, Broker>
where Broker: Unpin, TcpStack: Unpin, Clock: Unpin, <TcpStack as TcpClientStack>::TcpSocket: Unpin, <Clock as Clock>::T: Unpin,

§

impl<'buf, TcpStack, Clock, Broker> !UnwindSafe for MqttClient<'buf, TcpStack, Clock, Broker>

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

§

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

§

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.