mqute-codec - MQTT Packet Serialization Library
A feature-complete implementation of the MQTT (Message Queuing Telemetry Transport) protocol serialization in Rust, supporting versions 3.1, 3.1.1 and 5.0.
Description
mqute-codec is a zero-allocation MQTT packet serialization/deserialization library that provides:
- Packet construction: Build all MQTT packet types programmatically
- Wire format handling: Convert packets to/from their binary representation
- Protocol compliance: Strict validation of packet structure and fields
- Version support: MQTT 3.1, 3.1.1 and 5.0 packet formats
This is not a full MQTT client/broker implementation - it focuses exclusively on the packet layer, making it ideal for:
- Building custom MQTT clients/servers
- Protocol analysis tools
- Embedded systems requiring minimal overhead
- Testing and benchmarking implementations
Features
- Full support for MQTT 3.1, 3.1.1 and 5.0
- Zero-copy parsing for maximum performance
- Strict protocol compliance validation
- Flexible error handling system
- Async-ready design
Installation
Add to your Cargo.toml:
[]
= "0.1"
Usage Examples
Encoding a Connect Packet
use ;
use BytesMut;
let connect = new;
let mut buffer = new;
connect.encode.unwrap;
Decoding Packets
use ;
use BytesMut;
let mut codec = new;
let mut buffer = from;
match codec.decode
Supported MQTT Packets
- Connect/ConnAck
- Publish/PubAck/PubRec/PubRel/PubComp
- Subscribe/SubAck
- Unsubscribe/UnsubAck
- PingReq/PingResp
- Disconnect
- Auth (v5 only)
Documentation
Complete API documentation is available on docs.rs.
License
This project is licensed under the MIT License - see the LICENSE file for details.