Crate finmqtt_tokio

Crate finmqtt_tokio 

Expand description

Session-oriented MQTT v5 client built on [tokio] and finmqtt-core.

ยงQuick start

use finmqtt_core::wire::QoS;
use finmqtt_tokio::transport::TcpTransport;
use finmqtt_tokio::{ClientOptions, MqttClient, MqttString, TopicBuf, TopicFilterBuf};
use futures::StreamExt;

let transport = TcpTransport::new("broker.example.com", 1883);
let options = ClientOptions::new("my-client".parse()?).reconnect();

let (client, mut messages) = MqttClient::new(transport, options).await?;

// Subscribe โ€” pure protocol operation, returns SUBACK reason codes.
let reason_codes = client
    .subscribe("sensors/#".parse()?)
    .qos(QoS::AtLeastOnce)
    .send()
    .await?;

// Publish with v5 properties:
client
    .publish("sensors/temp".parse()?, b"22.5".as_slice())
    .qos(QoS::AtLeastOnce)
    .send()?;

// All messages arrive on the single message stream:
while let Some(msg) = messages.next().await {
    println!("{}: {:?}", msg.topic, msg.payload);
}

Re-exportsยง

pub use self::message::Message;
pub use self::message::MessageStream;
pub use self::options::ClientOptions;
pub use self::token::PublishToken;

Modulesยง

client ๐Ÿ”’
Session-oriented MQTT v5 client.
connection ๐Ÿ”’
Low-level single-connection driver.
error
Error types for the MQTT tokio client.
journal
Session journal: async file writer and replay.
message
MQTT v5 message type with full property support.
options
Client options with MQTT v5 connect properties and reconnect configuration.
publish ๐Ÿ”’
Publish builder with MQTT v5 property support.
subscribe ๐Ÿ”’
Subscribe builder with MQTT v5 option support.
token
Tokens for tracking the progress of MQTT operations.
transport
Modular transport layer.

Structsยง

MqttBytes
A byte slice that satisfies the MQTT v5 Binary Data length limit (at most 65 535 bytes).
MqttBytesBuf
Owned binary data that satisfies the MQTT v5 length limit.
MqttClient
A session-oriented MQTT v5 client.
MqttStr
A UTF-8 string that satisfies all MQTT v5 requirements:
MqttString
An owned UTF-8 string that satisfies all MQTT v5 requirements.
PacketId
MQTT Packet Identifier (ยง2.2.1).
PublishBuilder
Builder for publishing a message with optional MQTT v5 properties.
SubscribeBuilder
Builder for subscribing to a topic filter with MQTT v5 options.
SubscriptionOptions
Subscription options byte in a SUBSCRIBE payload entry.
Topic
A validated, borrowed MQTT topic name.
TopicBuf
An owned, validated MQTT topic name.
TopicFilter
A validated, borrowed MQTT topic filter.
TopicFilterBuf
An owned, validated MQTT topic filter.

Enumsยง

TopicError
Error returned when constructing a Topic, TopicFilter, or their owned counterparts.