pub struct AsyncClient { /* private fields */ }
Expand description
An asynchronous client, communicates with MQTT EventLoop
.
This is cloneable and can be used to asynchronously publish
,
subscribe
through the EventLoop
, which is to be polled parallelly.
NOTE: The EventLoop
must be regularly polled in order to send, receive and process packets
from the broker, i.e. move ahead.
Implementations§
Source§impl AsyncClient
impl AsyncClient
Sourcepub fn new(options: MqttOptions, cap: usize) -> (AsyncClient, EventLoop)
pub fn new(options: MqttOptions, cap: usize) -> (AsyncClient, EventLoop)
Create a new AsyncClient
.
cap
specifies the capacity of the bounded async channel.
Sourcepub fn from_senders(request_tx: Sender<(NoticeTx, Request)>) -> AsyncClient
pub fn from_senders(request_tx: Sender<(NoticeTx, Request)>) -> AsyncClient
Create a new AsyncClient
from a channel Sender
.
This is mostly useful for creating a test instance where you can listen on the corresponding receiver.
pub async fn publish_with_properties<S, P>( &self, topic: S, qos: QoS, retain: bool, payload: P, properties: PublishProperties, ) -> Result<NoticeFuture, ClientError>
pub async 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 async fn ack(&self, publish: &Publish) -> Result<NoticeFuture, ClientError>
pub async 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>
Attempts to send a MQTT PubAck to the EventLoop
. Only needed in if manual_acks
flag is set.
pub async fn publish_bytes_with_properties<S>( &self, topic: S, qos: QoS, retain: bool, payload: Bytes, properties: PublishProperties, ) -> Result<NoticeFuture, ClientError>
pub async fn publish_bytes<S>( &self, topic: S, qos: QoS, retain: bool, payload: Bytes, ) -> Result<NoticeFuture, ClientError>
pub async fn subscribe_with_properties<S: Into<String>>( &self, topic: S, qos: QoS, properties: SubscribeProperties, ) -> Result<NoticeFuture, ClientError>
pub async fn subscribe<S: Into<String>>( &self, topic: S, qos: QoS, ) -> Result<NoticeFuture, ClientError>
pub fn try_subscribe_with_properties<S: Into<String>>( &self, topic: S, qos: QoS, properties: SubscribeProperties, ) -> Result<NoticeFuture, ClientError>
pub fn try_subscribe<S: Into<String>>( &self, topic: S, qos: QoS, ) -> Result<NoticeFuture, ClientError>
pub async fn subscribe_many_with_properties<T>(
&self,
topics: T,
properties: SubscribeProperties,
) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = Filter>,
pub async 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 async fn unsubscribe_with_properties<S: Into<String>>( &self, topic: S, properties: UnsubscribeProperties, ) -> Result<NoticeFuture, ClientError>
pub async fn unsubscribe<S: Into<String>>( &self, topic: S, ) -> Result<NoticeFuture, ClientError>
pub fn try_unsubscribe_with_properties<S: Into<String>>( &self, topic: S, properties: UnsubscribeProperties, ) -> Result<NoticeFuture, ClientError>
pub fn try_unsubscribe<S: Into<String>>( &self, topic: S, ) -> Result<NoticeFuture, ClientError>
Sourcepub async fn disconnect(&self) -> Result<NoticeFuture, ClientError>
pub async 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>
Attempts to send a MQTT disconnect to the EventLoop
Trait Implementations§
Source§impl Clone for AsyncClient
impl Clone for AsyncClient
Source§fn clone(&self) -> AsyncClient
fn clone(&self) -> AsyncClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more