mqute_codec/protocol/mod.rs
1//! # MQTT Protocol Implementation
2//!
3//! This module provides complete implementations of MQTT protocol versions 3.1, 3.1.1, and 5.0,
4//! with shared components for packet handling and protocol logic.
5//!
6//! The implementation follows the official MQTT specification for each version and provides
7//! type-safe APIs for building, parsing, and handling MQTT packets.
8//!
9//! ## Examples
10//!
11//! ### Working with different protocol versions
12//! ```rust
13//! use std::time::Duration;
14//! use mqute_codec::protocol::{v4, v5, Protocol};
15//! use mqute_codec::protocol::QoS;
16//!
17//! // Create v3.1.1 CONNECT packet
18//! let connect_v4 = v4::Connect::new(
19//! "client_id",
20//! None,
21//! None,
22//! Duration::from_secs(30),
23//! true
24//! );
25//! assert_eq!(connect_v4.protocol(), Protocol::V4);
26//!
27//! // Create v5 CONNECT with properties
28//! let connect_v5 = v5::Connect::new(
29//! "client_id",
30//! None,
31//! None,
32//! Duration::from_secs(30),
33//! true
34//! );
35//! assert_eq!(connect_v5.protocol(), Protocol::V5);
36//! ```
37
38/// # Common Protocol Components
39///
40/// Shared types and utilities used across all MQTT protocol versions.
41/// Includes connection credentials, payload handling, and frame interfaces.
42mod common;
43
44/// # Packet Header Implementation
45///
46/// Handles fixed header parsing and construction for MQTT packets.
47/// Manages packet type, flags, and remaining length encoding.
48mod header;
49
50/// # Core Packet Types
51///
52/// Defines the fundamental MQTT packet types and their implementations.
53/// Includes packet encoding, decoding, and validation logic.
54mod packet;
55
56/// # Quality of Service Levels
57mod qos;
58
59/// # Protocol Utilities
60///
61/// Contains utility functions for MQTT protocol handling including:
62/// - Topic validation and filtering
63/// - Variable byte integer encoding
64/// - System topic detection
65pub mod util;
66
67/// # Protocol Version Handling
68///
69/// Manages protocol version negotiation and feature detection.
70/// Provides version-specific behavior and compatibility handling.
71mod version;
72
73/// # MQTT v3.1 Implementation
74///
75/// Complete implementation of the MQTT 3.1 specification (IBM version).
76///
77/// ## Key Features
78/// - Basic QoS 0-2 support with acknowledged delivery
79/// - Clean session handling for persistent connections
80/// - Last Will and Testament (LWT) message support
81/// - Basic authentication username/password support
82pub mod v3;
83
84/// # MQTT v3.1.1 Implementation
85///
86/// Implementation of MQTT 3.1.1 (OASIS Standard, most widely deployed version).
87///
88/// ## Differences from v3.1
89/// - Enhanced error handling with specific return codes
90/// - Improved session management with persistent sessions
91/// - Standardized protocol name and version identification
92/// - Clarified specification semantics and edge cases
93pub mod v4;
94
95/// # MQTT v5.0 Implementation
96///
97/// Complete implementation of MQTT 5.0 with modern features and enhancements.
98///
99/// ## Key Features
100/// - Enhanced authentication and authorization mechanisms
101/// - User properties for extensible metadata
102/// - Reason codes for detailed error reporting
103/// - Shared subscriptions for load balancing
104/// - Message expiry and topic aliasing
105/// - Flow control and quota management
106pub mod v5;
107
108/// Authentication credentials for MQTT connection
109pub use common::Credentials;
110/// Re-export common protocol types and payload handlers
111pub use common::payload::*;
112/// Packet header types and fixed header implementation
113pub use header::*;
114/// MQTT packet type definitions and identifiers
115pub use packet::PacketType;
116/// Quality of Service level enumeration and functionality
117pub use qos::QoS;
118/// Protocol version handling and negotiation
119pub use version::*;