Unified Sans-I/O protocol entry point dispatching between MQTT 3.1.1 (V311)
and MQTT 5.0 (V5) codecs.
Version Selection
Supported version identifiers (all normalized to :"3.1.1" or :"5.0"):
- MQTT 3.1.1:
:"3.1.1",:v311,4,"3.1.1" - MQTT 5.0:
:"5.0",:v5,5,"5.0"
Summary
Functions
Returns the codec module for the given normalized protocol version.
Decodes a single MQTT packet from the front of buffer.
Decodes all complete MQTT packets from buffer, returning {:ok, packets, remaining_buffer}
or {:error, reason} if a malformed packet is encountered.
Encodes an ExMqtt.Protocol.Packet struct into iodata for version.
Encodes a packet directly into a flat binary.
Normalizes user-provided protocol version into :"3.1.1" or :"5.0".
Same as normalize_version/1 but raises on unsupported version.
Types
Functions
Returns the codec module for the given normalized protocol version.
@spec decode(binary(), version_input()) :: {:ok, ExMqtt.Protocol.Packet.t(), binary()} | :incomplete | {:error, term()}
Decodes a single MQTT packet from the front of buffer.
Returns:
{:ok, packet, rest}when a complete packet was decoded:incompletewhen more bytes are needed from the transport{:error, reason}when the packet violates the selected protocol version
@spec decode_all(binary(), version_input()) :: {:ok, [ExMqtt.Protocol.Packet.t()], binary()} | {:error, term()}
Decodes all complete MQTT packets from buffer, returning {:ok, packets, remaining_buffer}
or {:error, reason} if a malformed packet is encountered.
@spec encode(ExMqtt.Protocol.Packet.t(), version_input()) :: {:ok, iodata()} | {:error, term()}
Encodes an ExMqtt.Protocol.Packet struct into iodata for version.
@spec encode_binary(ExMqtt.Protocol.Packet.t(), version_input()) :: {:ok, binary()} | {:error, term()}
Encodes a packet directly into a flat binary.
@spec normalize_version(version_input()) :: {:ok, version()} | {:error, {:unsupported_version, term()}}
Normalizes user-provided protocol version into :"3.1.1" or :"5.0".
@spec normalize_version!(version_input()) :: version()
Same as normalize_version/1 but raises on unsupported version.