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 std::time::Duration;
use mqute_codec::protocol::{v5::Connect, Credentials};
let connect = Connect::new(
"client_id",
Some(Credentials::full("user", "pass")),
None,
Duration::from_secs(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.
The implementation follows the official MQTT specification for each version and provides type-safe APIs for building, parsing, and handling MQTT packets.
§Examples
§Working with different protocol versions
use std::time::Duration;
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,
Duration::from_secs(30),
true
);
assert_eq!(connect_v4.protocol(), Protocol::V4);
// Create v5 CONNECT with properties
let connect_v5 = v5::Connect::new(
"client_id",
None,
None,
Duration::from_secs(30),
true
);
assert_eq!(connect_v5.protocol(), Protocol::V5);Modules§
- traits
- Auxiliary Packet Traits
- util
- Protocol Utilities
- v3
- MQTT v3.1 Implementation
- v4
- MQTT v3.1.1 Implementation
- v5
- MQTT v5.0 Implementation
Structs§
- Codes
- Re-export common protocol types and payload handlers
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
- Authentication credentials for MQTT connection Represents authentication information for an MQTT connection.
- Fixed
Header - Packet header types and fixed header implementation Represents the fixed header of an MQTT packet.
- Flags
- Packet header types and fixed header implementation Represents the control flags in an MQTT packet.
- Topic
Filters - Re-export common protocol types and payload handlers A collection of MQTT topic filters used in subscription and unsubscription operations.
Enums§
- Packet
Type - MQTT packet type definitions and identifiers Represents the type of MQTT packet.
- Protocol
- Protocol version handling and negotiation Represents the MQTT protocol version.
- QoS
- Quality of Service level enumeration and functionality Represents the Quality of Service (QoS) levels in MQTT.