pub struct Client { /* private fields */ }
Expand description
A synchronous client, communicates with MQTT EventLoop
.
This is cloneable and can be used to synchronously publish
,
subscribe
through the EventLoop
/Connection
, which is to be polled in parallel
by iterating over the object returned by Connection.iter()
in a separate thread.
NOTE: The EventLoop
/Connection
must be regularly polled(.next()
in case of Connection
) in order
to send, receive and process packets from the broker, i.e. move ahead.
An asynchronous channel handle can also be extracted if necessary.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(options: MqttOptions, cap: usize) -> (Client, Connection)
pub fn new(options: MqttOptions, cap: usize) -> (Client, Connection)
Create a new Client
cap
specifies the capacity of the bounded async channel.
Sourcepub fn from_sender(request_tx: Sender<(NoticeTx, Request)>) -> Client
pub fn from_sender(request_tx: Sender<(NoticeTx, Request)>) -> Client
Create a new Client
from a channel Sender
.
This is mostly useful for creating a test instance where you can listen on the corresponding receiver.
pub fn publish_with_properties<S, P>( &self, topic: S, qos: QoS, retain: bool, payload: P, properties: PublishProperties, ) -> Result<NoticeFuture, ClientError>
pub fn publish<S, P>( &self, topic: S, qos: QoS, retain: bool, payload: P, ) -> Result<NoticeFuture, ClientError>
pub fn try_publish_with_properties<S, P>( &self, topic: S, qos: QoS, retain: bool, payload: P, properties: PublishProperties, ) -> Result<NoticeFuture, ClientError>
pub fn try_publish<S, P>( &self, topic: S, qos: QoS, retain: bool, payload: P, ) -> Result<NoticeFuture, ClientError>
Sourcepub fn ack(&self, publish: &Publish) -> Result<NoticeFuture, ClientError>
pub fn ack(&self, publish: &Publish) -> Result<NoticeFuture, ClientError>
Sends a MQTT PubAck to the EventLoop
. Only needed in if manual_acks
flag is set.
Sourcepub fn try_ack(&self, publish: &Publish) -> Result<NoticeFuture, ClientError>
pub fn try_ack(&self, publish: &Publish) -> Result<NoticeFuture, ClientError>
Sends a MQTT PubAck to the EventLoop
. Only needed in if manual_acks
flag is set.
pub fn subscribe_with_properties<S: Into<String>>( &self, topic: S, qos: QoS, properties: SubscribeProperties, ) -> Result<NoticeFuture, ClientError>
pub fn subscribe<S: Into<String>>( &self, topic: S, qos: QoS, ) -> Result<NoticeFuture, ClientError>
Sourcepub fn try_subscribe_with_properties<S: Into<String>>(
&self,
topic: S,
qos: QoS,
properties: SubscribeProperties,
) -> Result<NoticeFuture, ClientError>
pub fn try_subscribe_with_properties<S: Into<String>>( &self, topic: S, qos: QoS, properties: SubscribeProperties, ) -> Result<NoticeFuture, ClientError>
Sends a MQTT Subscribe to the EventLoop
pub fn try_subscribe<S: Into<String>>( &self, topic: S, qos: QoS, ) -> Result<NoticeFuture, ClientError>
pub fn subscribe_many_with_properties<T>(
&self,
topics: T,
properties: SubscribeProperties,
) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = Filter>,
pub fn subscribe_many<T>(&self, topics: T) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = Filter>,
pub fn try_subscribe_many_with_properties<T>(
&self,
topics: T,
properties: SubscribeProperties,
) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = Filter>,
pub fn try_subscribe_many<T>(
&self,
topics: T,
) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = Filter>,
pub fn unsubscribe_with_properties<S: Into<String>>( &self, topic: S, properties: UnsubscribeProperties, ) -> Result<NoticeFuture, ClientError>
pub fn unsubscribe<S: Into<String>>( &self, topic: S, ) -> Result<NoticeFuture, ClientError>
Sourcepub fn try_unsubscribe_with_properties<S: Into<String>>(
&self,
topic: S,
properties: UnsubscribeProperties,
) -> Result<NoticeFuture, ClientError>
pub fn try_unsubscribe_with_properties<S: Into<String>>( &self, topic: S, properties: UnsubscribeProperties, ) -> Result<NoticeFuture, ClientError>
Sends a MQTT Unsubscribe to the EventLoop
pub fn try_unsubscribe<S: Into<String>>( &self, topic: S, ) -> Result<NoticeFuture, ClientError>
Sourcepub fn disconnect(&self) -> Result<NoticeFuture, ClientError>
pub fn disconnect(&self) -> Result<NoticeFuture, ClientError>
Sends a MQTT disconnect to the EventLoop
Sourcepub fn try_disconnect(&self) -> Result<NoticeFuture, ClientError>
pub fn try_disconnect(&self) -> Result<NoticeFuture, ClientError>
Sends a MQTT disconnect to the EventLoop