pub enum Version {
Undetermined = 0,
V3_1_1 = 4,
V5_0 = 5,
}
Expand description
MQTT protocol version enumeration
Represents the supported MQTT protocol versions. Each variant corresponds to the protocol level value as defined in the MQTT specification. This is used throughout the library to handle version-specific behavior and feature availability.
§Protocol Level Values
The numeric values correspond to the Protocol Level field in the CONNECT packet:
- v3.1.1 uses protocol level 4
- v5.0 uses protocol level 5
Undetermined
is used by servers to accept any supported version
§Examples
use mqtt_protocol_core::mqtt::version::Version;
// Client specifies a specific version
let client_version = Version::V5_0;
// Server accepts any supported version
let server_version = Version::Undetermined;
match server_version {
Version::V3_1_1 => println!("Using MQTT v3.1.1"),
Version::V5_0 => println!("Using MQTT v5.0"),
Version::Undetermined => println!("Waiting for client CONNECT to determine version"),
}
Variants§
Undetermined = 0
Version to be determined by incoming CONNECT packet
Used by MQTT servers to indicate that the protocol version should be determined based on the protocol level in the incoming CONNECT packet from the client. The server will accept either v3.1.1 or v5.0 connections and adapt accordingly. Not a valid protocol level value itself.
V3_1_1 = 4
MQTT version 3.1.1 (protocol level 4)
The widely adopted MQTT v3.1.1 specification. This version provides the core MQTT functionality including QoS levels, retained messages, last will and testament, and persistent sessions.
V5_0 = 5
MQTT version 5.0 (protocol level 5)
The latest MQTT specification with enhanced features including:
- User properties and reason codes
- Topic aliases and subscription identifiers
- Message expiry and session expiry intervals
- Enhanced authentication (AUTH packets)
- Improved error handling and flow control