Expand description
§Protocol Implementation
Contains all MQTT packet definitions and protocol logic.
§Organization
v3: MQTT v3.1 protocol implementationv4: MQTT v3.1.1 protocol implementationv5: MQTT v5.0 protocol implementationcommon: Shared types between protocol versions
§Example: Creating a CONNECT Packet
use mqute_codec::protocol::{v5::Connect, Credentials};
let connect = Connect::new(
"client_id",
Some(Credentials::login("user", "pass")),
None,
30, // keep alive
true // clean session
);§Example: Creating a PUBLISH Packet
use mqute_codec::protocol::v4::{Publish};
use mqute_codec::protocol::{Flags, QoS};
use bytes::Bytes;
let flag = Flags::new(QoS::AtLeastOnce);
let publish = Publish::new(
"topic",
1234,
Bytes::from("payload"),
flag
);§MQTT Protocol Implementation
This module provides complete implementations of MQTT protocol versions 3.1, 3.1.1, and 5.0, with shared components for packet handling and protocol logic.
§Examples
§Working with different protocol versions
use mqute_codec::protocol::{v4, v5, Protocol};
use mqute_codec::protocol::QoS;
// Create v3.1.1 CONNECT packet
let connect_v4 = v4::Connect::new(
"client_id",
None,
None,
30,
true
);
assert_eq!(connect_v4.protocol(), Protocol::V4);
// Create v5 CONNECT with properties
let connect_v5 = v5::Connect::new(
"client_id",
None,
None,
30,
true
);
assert_eq!(connect_v5.protocol(), Protocol::V5);Modules§
Structs§
- Codes
- Re-export common protocol types
The
Codesmodule provides a generic structure to handle a collection of MQTT return codes. These codes are used in various MQTT control packets, such as ConnAck, SubAck, and UnsubAck. - Credentials
- Represents authentication information for an MQTT connection.
- Fixed
Header - Represents the fixed header of an MQTT packet.
- Flags
- Represents the control flags in an MQTT packet.
- Topic
Filters - Re-export common protocol types
The
TopicFiltersprovides a structure to handle a collection of MQTT topic filters. Topic filters are used in MQTT subscriptions and unsubscriptions.
Enums§
- Packet
Type - Represents the type of MQTT packet.
- Protocol
- Represents the MQTT protocol version.
- QoS
- Represents the Quality of Service (QoS) levels in MQTT.