Skip to main content

Crate mqtt_proto

Crate mqtt_proto 

Source
Expand description

MQTT wire protocol: packet encoding/decoding for both MQTT 3.1.1 and MQTT 5.0.

This crate has no networking, async or TLS dependencies: it is a pure, synchronous codec so it can be unit-tested byte-for-byte and reused by the stem-mqtt-client connection loop, the stem-mqtt-broker, and firmware on embedded targets that bring their own transport.

Re-exports§

pub use error::MqttError;
pub use error::MqttResult;
pub use ack::*;
pub use connect::*;
pub use packet::*;
pub use properties::*;
pub use publish::*;
pub use subscribe::*;

Modules§

ack
PUBACK / PUBREC / PUBREL / PUBCOMP packets. All four share an identical wire shape (MQTT-5.0 §3.4, §3.5, §3.6, §3.7): a packet id, and — in MQTT 5.0, when there’s anything interesting to say — a reason code and properties.
connect
CONNECT / CONNACK packets (MQTT-3.1.1 §3.1, §3.2; MQTT-5.0 §3.1, §3.2).
error
Error type shared by the codec, the client and the broker.
packet
Top-level Packet enum: the fixed header, remaining-length framing, and dispatch to each packet type’s body codec.
properties
MQTT 5.0 Properties (MQTT-5.0 §2.2.2). Absent entirely in MQTT 3.1.1.
publish
PUBLISH packet (MQTT-3.1.1 §3.3; MQTT-5.0 §3.3).
subscribe
SUBSCRIBE / SUBACK / UNSUBSCRIBE / UNSUBACK packets (MQTT-3.1.1 §3.8-§3.11; MQTT-5.0 §3.8-§3.11).
support
Debug helpers that never print passwords or private keys (so a stray {:?} or tracing::debug!(?options) cannot leak credentials into logs). Re-exported by stem-mqtt-client under its support module.
topic
MQTT topic name / topic filter matching and validation (MQTT-3.1.1 §4.7; MQTT-5.0 §4.7), including the + (single-level) and # (multi-level) wildcards and the $-prefixed “system topic” exclusion rule.
varint
Wire-format primitives shared by every MQTT packet: the Variable Byte Integer encoding, length-prefixed UTF-8 strings, and length-prefixed binary data, as defined by the MQTT 3.1.1 and MQTT 5.0 specifications.

Macros§

redacted_debug
Implements Debug for a struct, printing the listed fields normally and the secret fields as <redacted>.

Enums§

MqttVersion
The MQTT protocol version negotiated for a connection.
QoS
MQTT Quality of Service level.