Struct rumqttc::AsyncClient
source · [−]pub struct AsyncClient { /* private fields */ }
Expand description
AsyncClient
to communicate with MQTT Eventloop
This is cloneable and can be used to asynchronously Publish, Subscribe.
Implementations
sourceimpl 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
sourcepub fn from_senders(
request_tx: Sender<Request>,
cancel_tx: Sender<()>
) -> AsyncClient
pub fn from_senders(
request_tx: Sender<Request>,
cancel_tx: Sender<()>
) -> AsyncClient
Create a new AsyncClient
from a pair of async channel Sender
s. This is mostly useful for
creating a test instance.
sourcepub async fn publish<S, V>(
&self,
topic: S,
qos: QoS,
retain: bool,
payload: V
) -> Result<(), ClientError> where
S: Into<String>,
V: Into<Vec<u8>>,
pub async fn publish<S, V>(
&self,
topic: S,
qos: QoS,
retain: bool,
payload: V
) -> Result<(), ClientError> where
S: Into<String>,
V: Into<Vec<u8>>,
Sends a MQTT Publish to the eventloop
sourcepub fn try_publish<S, V>(
&self,
topic: S,
qos: QoS,
retain: bool,
payload: V
) -> Result<(), ClientError> where
S: Into<String>,
V: Into<Vec<u8>>,
pub fn try_publish<S, V>(
&self,
topic: S,
qos: QoS,
retain: bool,
payload: V
) -> Result<(), ClientError> where
S: Into<String>,
V: Into<Vec<u8>>,
Sends a MQTT Publish to the eventloop
sourcepub async fn ack(&self, publish: &Publish) -> Result<(), ClientError>
pub async fn ack(&self, publish: &Publish) -> Result<(), 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<(), ClientError>
pub fn try_ack(&self, publish: &Publish) -> Result<(), ClientError>
Sends 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<(), ClientError> where
S: Into<String>,
pub async fn publish_bytes<S>(
&self,
topic: S,
qos: QoS,
retain: bool,
payload: Bytes
) -> Result<(), ClientError> where
S: Into<String>,
Sends a MQTT Publish to the eventloop
sourcepub async fn subscribe<S: Into<String>>(
&self,
topic: S,
qos: QoS
) -> Result<(), ClientError>
pub async fn subscribe<S: Into<String>>(
&self,
topic: S,
qos: QoS
) -> Result<(), ClientError>
Sends a MQTT Subscribe to the eventloop
sourcepub fn try_subscribe<S: Into<String>>(
&self,
topic: S,
qos: QoS
) -> Result<(), ClientError>
pub fn try_subscribe<S: Into<String>>(
&self,
topic: S,
qos: QoS
) -> Result<(), ClientError>
Sends a MQTT Subscribe to the eventloop
sourcepub async fn subscribe_many<T>(&self, topics: T) -> Result<(), ClientError> where
T: IntoIterator<Item = SubscribeFilter>,
pub async fn subscribe_many<T>(&self, topics: T) -> Result<(), 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<(), ClientError> where
T: IntoIterator<Item = SubscribeFilter>,
pub fn try_subscribe_many<T>(&self, topics: T) -> Result<(), ClientError> where
T: IntoIterator<Item = SubscribeFilter>,
Sends a MQTT Subscribe for multiple topics to the eventloop
sourcepub async fn unsubscribe<S: Into<String>>(
&self,
topic: S
) -> Result<(), ClientError>
pub async fn unsubscribe<S: Into<String>>(
&self,
topic: S
) -> Result<(), ClientError>
Sends a MQTT Unsubscribe to the eventloop
sourcepub fn try_unsubscribe<S: Into<String>>(
&self,
topic: S
) -> Result<(), ClientError>
pub fn try_unsubscribe<S: Into<String>>(
&self,
topic: S
) -> Result<(), ClientError>
Sends a MQTT Unsubscribe to the eventloop
sourcepub async fn disconnect(&self) -> Result<(), ClientError>
pub async fn disconnect(&self) -> Result<(), ClientError>
Sends a MQTT disconnect to the eventloop
sourcepub fn try_disconnect(&self) -> Result<(), ClientError>
pub fn try_disconnect(&self) -> Result<(), ClientError>
Sends a MQTT disconnect to the eventloop
sourcepub async fn cancel(&self) -> Result<(), ClientError>
pub async fn cancel(&self) -> Result<(), ClientError>
Stops the eventloop right away
Trait Implementations
sourceimpl Clone for AsyncClient
impl Clone for AsyncClient
sourcefn clone(&self) -> AsyncClient
fn clone(&self) -> AsyncClient
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for AsyncClient
impl Send for AsyncClient
impl Sync for AsyncClient
impl Unpin for AsyncClient
impl UnwindSafe for AsyncClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more