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.
Sourcepub async fn publish<S, V>(
&self,
topic: S,
qos: QoS,
retain: bool,
payload: V,
) -> Result<NoticeFuture, ClientError>
pub async fn publish<S, V>( &self, topic: S, qos: QoS, retain: bool, payload: V, ) -> Result<NoticeFuture, ClientError>
Sends a MQTT Publish to the EventLoop
.
Sourcepub fn try_publish<S, V>(
&self,
topic: S,
qos: QoS,
retain: bool,
payload: V,
) -> Result<NoticeFuture, ClientError>
pub fn try_publish<S, V>( &self, topic: S, qos: QoS, retain: bool, payload: V, ) -> Result<NoticeFuture, ClientError>
Attempts to send a MQTT Publish to the EventLoop
.
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.
Sourcepub async fn publish_bytes<S>(
&self,
topic: S,
qos: QoS,
retain: bool,
payload: Bytes,
) -> Result<NoticeFuture, ClientError>
pub async fn publish_bytes<S>( &self, topic: S, qos: QoS, retain: bool, payload: Bytes, ) -> Result<NoticeFuture, ClientError>
Sends a MQTT Publish to the EventLoop
Sourcepub async fn subscribe<S: Into<String>>(
&self,
topic: S,
qos: QoS,
) -> Result<NoticeFuture, ClientError>
pub async fn subscribe<S: Into<String>>( &self, topic: S, qos: QoS, ) -> Result<NoticeFuture, ClientError>
Sends a MQTT Subscribe to the EventLoop
Sourcepub fn try_subscribe<S: Into<String>>(
&self,
topic: S,
qos: QoS,
) -> Result<NoticeFuture, ClientError>
pub fn try_subscribe<S: Into<String>>( &self, topic: S, qos: QoS, ) -> Result<NoticeFuture, ClientError>
Attempts to send a MQTT Subscribe to the EventLoop
Sourcepub async fn subscribe_many<T>(
&self,
topics: T,
) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = SubscribeFilter>,
pub async fn subscribe_many<T>(
&self,
topics: T,
) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = SubscribeFilter>,
Sends a MQTT Subscribe for multiple topics to the EventLoop
Sourcepub fn try_subscribe_many<T>(
&self,
topics: T,
) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = SubscribeFilter>,
pub fn try_subscribe_many<T>(
&self,
topics: T,
) -> Result<NoticeFuture, ClientError>where
T: IntoIterator<Item = SubscribeFilter>,
Attempts to send a MQTT Subscribe for multiple topics to the EventLoop
Sourcepub async fn unsubscribe<S: Into<String>>(
&self,
topic: S,
) -> Result<NoticeFuture, ClientError>
pub async fn unsubscribe<S: Into<String>>( &self, topic: S, ) -> Result<NoticeFuture, ClientError>
Sends a MQTT Unsubscribe to the EventLoop
Sourcepub fn try_unsubscribe<S: Into<String>>(
&self,
topic: S,
) -> Result<NoticeFuture, ClientError>
pub fn try_unsubscribe<S: Into<String>>( &self, topic: S, ) -> Result<NoticeFuture, ClientError>
Attempts to send a MQTT Unsubscribe to the EventLoop
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