mqute-codec - MQTT Packet Serialization Library
A feature-complete, zero-allocation implementation of MQTT (Message Queuing Telemetry Transport) protocol serialization in Rust, supporting versions 3.1, 3.1.1, and 5.0 with strict protocol compliance and validation.
Description
mqute-codec is a high-performance MQTT packet serialization/deserialization library designed for building robust MQTT clients, brokers, and protocol tools. It provides:
- Complete Packet Handling: Full support for all MQTT packet types across all protocol versions
- Zero-Copy Parsing: Maximum performance with minimal memory overhead
- Protocol Compliance: Strict validation of packet structure, fields, and protocol rules
- Version Support: MQTT 3.1, 3.1.1, and 5.0 with version-specific features
- Async-Ready: Designed for seamless integration with async runtimes
This library focuses exclusively on the packet layer, making it ideal for:
- Building custom MQTT clients and brokers
- Protocol analysis and diagnostic tools
- Embedded systems requiring minimal memory footprint
- Testing and benchmarking MQTT implementations
- Educational purposes for understanding MQTT protocol internals
Features
Core Features
- Full Protocol Support: MQTT 3.1, 3.1.1, and 5.0 packet formats
- Zero-Copy Architecture: Minimal allocations for maximum performance
- Strict Validation: Comprehensive protocol compliance checking
- Flexible Error Handling: Detailed error types with context information
- Async Integration: Ready for use with tokio and other async runtimes
MQTT v5 Specific Features
- Property Support: Full implementation of MQTT v5 properties
- Enhanced Authentication: Auth packet and extended authentication flows
- Reason Codes: Detailed error and status reporting
- User Properties: Custom metadata support
- Shared Subscriptions: Load balancing and group messaging
Performance Features
- Zero Allocation Parsing: For most common packet types
- Buffer Reuse: Efficient memory management
- Batch Processing: Optimized for high-throughput scenarios
- Minimal Dependencies: Lightweight dependency tree
Installation
Add to your Cargo.toml:
[]
= "0.4"
Usage Examples
Encoding and Decoding a Connect Packet
use ;
use ;
use Duration;
use ;
use ;
use ;
Basic MQTT Server Implementation
use Packet;
use ;
use TcpListener;
use Framed;
use StreamExt;
async
async
Supported MQTT Packets
- Connect/ConnAck
- Publish/PubAck/PubRec/PubRel/PubComp
- Subscribe/SubAck
- Unsubscribe/UnsubAck
- PingReq/PingResp
- Disconnect
MQTT v5 Exclusive
- Auth - Enhanced authentication flows
- Property Support - Full property encoding/decoding
- Reason Codes - Detailed status reporting
Performance Characteristics
- Zero Allocation: Most packet types parsed without heap allocations
- Memory Efficient: Minimal memory footprint
Documentation
Complete API documentation is available on docs.rs.
License
This project is licensed under the MIT License - see the LICENSE file for details.