Module paho_mqtt::async_client

source ·
Expand description

The asynchronous API The Asynchronous client module for the Paho MQTT Rust client library.

This presents an asynchronous API that is similar to the other Paho MQTT clients, but uses Token objects that implement the Futures trait, so can be used in much more flexible ways than the other language clients.

Asynchronous operations return a Token that is a type of future. It can be used to determine if an operation has completed, block and wait for the operation to complete, and obtain the final result. For example, you can start a connection, do something else, and then wait for the connection to complete.

use futures::future::Future;
use paho_mqtt as mqtt;

let cli = mqtt::AsyncClient::new("tcp://localhost:1883").unwrap();

// Start an async operation and get the token for it.
let tok = cli.connect(mqtt::ConnectOptions::new());

// ...do something else...

// Wait for the async operation to complete.
tok.wait().unwrap();

Structs

Type Aliases