Expand description
encode/decode MQTT fundamental types
Functionsยง
- read_
binary_ data - Read from the given reader for binary dataset according to Binary Data type
MQTT5 specifications which consists in an two bytes integer representing
the data size in bytes followed with the data as bytes.
In case of success, returns a
Vec<u8>
- read_
bool - Read the given
reader
for a boolean value. MQTT5 specifications do not define an actual boolean type but expresses it with a byte being0x00
forfalse
or0x01
forfalse
. Other values are considered incorrect. In case of success, returns anbool
- read_
byte - Read the given
reader
for a byte value. In case of success, returns anu8
- read_
control_ packet_ type - Read the given
reader
for aPacketType
. In case of success, returns aPacketType
instance. - read_
four_ byte_ integer - Read the given
reader
for anu32
, returning it in case of success. - read_
qos - Read the given reader for a
QoS
, returning it in case of success. - read_
two_ byte_ integer - Read the given
reader
for anu16
, returning it in case of success. - read_
utf8_ string - Read from the given reader for binary dataset according to Binary Data type
MQTT5 specifications which consists in an two bytes integer representing
the data size in bytes followed with the data as bytes.
In case of success, returns a
Vec<u8>
- read_
variable_ byte_ integer - Read the given stream for a
u32
encoded as Variable Byte Integer. Returns the read value in case of success. - write_
binary_ data - Write the given
data
intowriter
according to Binary Data type MQTT5 specifications which consists in a two bytes integer representing the data size in bytes followed with the data as bytes. In case of success returns the written size in bytes. - write_
bool - Write the given bool into
writer
in a single byte value. MQTT5 specifications do not define an actual boolean type but expresses it with a byte being0x00
forfalse
or0x01
forfalse
. Other values are considered incorrect. In case of success, returns1
- write_
byte - Write the given byte into
writer
. In case of success, returns1
- write_
control_ packet_ type - Write the given
PacketType
in one byte according to MQTT5 specifications. In case of success, returns1
. - write_
four_ byte_ integer - Write the given
u32
according to MQTT5 Four Byte Integer specifications. In case of success, returns4
. - write_
qos - Write the given
QoS
instance in one byte. In case of success, returns1
. - write_
reason_ code - Write the given
ReasonCode
in one byte, returning1
in case of success. - write_
two_ byte_ integer - Write the given
u16
according to MQTT5 Two Byte Integer specifications. In case of success, returns2
. - write_
utf8_ string - Write the given string into
writer
according to UTF8 String type MQTT5 specifications which consists in a two bytes integer representing the string size in bytes followed with the string as bytes. In case of success returns the written size in bytes. - write_
variable_ byte_ integer - Write the given
u32
intowriter
according to MQTT5 Variable Byte Integer specifications, returning the number of bytes written (1
,2
,3
or4
) in case of success.