Skip to main content

Crate symqtt_codec

Crate symqtt_codec 

Source
Expand description

MQTT 3.1.1 / 5.0 packet codec

Role-neutral encoder/decoder for client and server packets. No async runtime. Framing is in v3::Packet::decode / v5::Packet::decode: a partial packet returns Ok(None) and consumes nothing.

§Modules

  • v3 — MQTT 3.1.1 packets
  • v5 — MQTT 5.0 packets, properties, reason codes

§Example

use bytes::BytesMut;
use symqtt_codec::v3::{Packet, Subscribe, SubscribeFilter};
use symqtt_codec::QoS;

let mut wire = BytesMut::new();
Packet::Subscribe(Subscribe {
    pkid: 1,
    filters: vec![SubscribeFilter { topic: "a/b".to_owned(), qos: QoS::AtLeastOnce }],
})
.encode(&mut wire)?;

// Framing lives in decode: a partial packet yields Ok(None) and consumes nothing
let packet = Packet::decode(&mut wire)?.expect("a whole packet");

Modules§

v3
MQTT v3.1.1 packet encoding and decoding [MQTT-3]
v5
MQTT v5.0 packet encoding and decoding [MQTTv5-3]

Enums§

DecodeError
Errors that may occur while decoding an MQTT packet from the wire
EncodeError
Errors that may occur while encoding an MQTT packet to the wire
PacketType
MQTT control packet type [MQTT-2.2.1, Table 2.1]
QoS
MQTT Quality of Service level [MQTT-4.3]

Constants§

MAX_REMAINING_LEN
Largest remaining length the four-byte variable-length integer can express [MQTT-2.2.3]