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>
impl<'buf, TcpStack: TcpClientStack, Clock: Clock, Broker: Broker> MqttClient<'buf, TcpStack, Clock, Broker>
sourcepub fn subscribe(
&mut self,
topics: &[TopicFilter<'_>],
properties: &[Property<'_>]
) -> Result<(), Error<TcpStack::Error>>
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 ofTopicFilter
s to subscribe to.properties
- A list of properties to attach to the subscription request. May be empty.
sourcepub fn subscriptions_pending(&self) -> bool
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.
sourcepub fn is_connected(&mut self) -> bool
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.
sourcepub fn pending_messages(&self) -> bool
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.
sourcepub fn can_publish(&self, qos: QoS) -> bool
pub fn can_publish(&self, qos: QoS) -> bool
sourcepub fn publish<P: ToPayload>(
&mut self,
publish: Pub<'_, P>
) -> Result<(), PubError<TcpStack::Error, P::Error>>
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.