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
57///
58/// Implements MQTT Quality of Service (QoS) levels with full specification
59/// compliance.
60mod qos;
61
62/// # Protocol Utilities
63///
64/// Contains utility functions for MQTT protocol handling including:
65/// - Topic validation and filtering
66/// - Variable byte integer encoding
67/// - System topic detection
68pub mod util;
69
70/// # Protocol Version Handling
71///
72/// Manages protocol version negotiation and feature detection.
73/// Provides version-specific behavior and compatibility handling.
74mod version;
75
76/// # MQTT v3.1 Implementation
77///
78/// Complete implementation of the MQTT 3.1 specification (IBM version).
79///
80/// ## Key Features
81/// - Basic QoS 0-2 support with acknowledged delivery
82/// - Clean session handling for persistent connections
83/// - Last Will and Testament (LWT) message support
84/// - Basic authentication username/password support
85pub mod v3;
86
87/// # MQTT v3.1.1 Implementation
88///
89/// Implementation of MQTT 3.1.1 (OASIS Standard, most widely deployed version).
90///
91/// ## Differences from v3.1
92/// - Enhanced error handling with specific return codes
93/// - Improved session management with persistent sessions
94/// - Standardized protocol name and version identification
95/// - Clarified specification semantics and edge cases
96pub mod v4;
97
98/// # MQTT v5.0 Implementation
99///
100/// Complete implementation of MQTT 5.0 with modern features and enhancements.
101///
102/// ## Key Features
103/// - Enhanced authentication and authorization mechanisms
104/// - User properties for extensible metadata
105/// - Reason codes for detailed error reporting
106/// - Shared subscriptions for load balancing
107/// - Message expiry and topic aliasing
108/// - Flow control and quota management
109pub mod v5;
110
111/// # Auxiliary Packet Traits
112///
113/// Provides generic traits for MQTT packet functionality across protocol versions.
114/// These auxiliary traits enable version-agnostic code while maintaining type safety.
115pub mod traits;
116
117/// Authentication credentials for MQTT connection
118pub use common::Credentials;
119/// Re-export common protocol types and payload handlers
120pub use common::payload::*;
121/// Packet header types and fixed header implementation
122pub use header::*;
123/// MQTT packet type definitions and identifiers
124pub use packet::PacketType;
125/// Quality of Service level enumeration and functionality
126pub use qos::QoS;
127/// Protocol version handling and negotiation
128pub use version::*;