mqtt_packet_map (mqtt_packet_map v1.3.1)
View SourceMQTT packet encoder/decoder
Summary
Functions
Check if a binary contains a complete packet within the maximum packet size.
Encode a MQTT message to a binary.
Encode a MQTT message to a binary.
Return the full packet size, including the fixed header, when available.
Types
-type decode_error() :: incomplete_packet | malformed_header | unknown_protocol | invalid_packet | invalid_topic | malformed_packet | {unknown_property, integer()}.
-type mqtt_packet() :: map().
-type mqtt_topic() :: [mqtt_topic_part()] | binary().
-type mqtt_version() :: undefined | 3 | 4 | 5.
-type packet_size_error() :: malformed_packet | packet_too_large.
Functions
-spec check_packet_size(binary(), pos_integer() | undefined) -> ok | incomplete | {error, packet_size_error()}.
Check if a binary contains a complete packet within the maximum packet size.
-spec decode(binary()) -> {ok, {mqtt_packet(), binary()}} | {error, decode_error()}.
-spec decode(mqtt_version(), binary()) -> {ok, {mqtt_packet(), binary()}} | {error, decode_error()}.
-spec encode(mqtt_packet()) -> {ok, binary()} | {error, term()}.
Encode a MQTT message to a binary.
-spec encode(mqtt_version(), mqtt_packet()) -> {ok, binary()} | {error, term()}.
Encode a MQTT message to a binary.
-spec packet_size(binary()) -> {ok, non_neg_integer()} | incomplete | {error, malformed_packet}.
Return the full packet size, including the fixed header, when available.