Module sage_mqtt::codec[][src]

Expand description

encode/decode MQTT fundamental types

Functions

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 the given reader for a boolean value. MQTT5 specifications do not define an actual boolean type but expresses it with a byte being 0x00 for false or 0x01 for false. Other values are considered incorrect. In case of success, returns an bool

Read the given reader for a byte value. In case of success, returns an u8

Read the given reader for a PacketType. In case of success, returns a PacketType instance.

Read the given reader for an u32, returning it in case of success.

Read the given reader for a QoS, returning it in case of success.

Read the given reader for an u16, returning it in case of success.

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 the given stream for a u32 encoded as Variable Byte Integer. Returns the read value in case of success.

Write the given data into writer 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 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 being 0x00 for false or 0x01 for false. Other values are considered incorrect. In case of success, returns 1

Write the given byte into writer. In case of success, returns 1

Write the given PacketType in one byte according to MQTT5 specifications. In case of success, returns 1.

Write the given u32 according to MQTT5 Four Byte Integer specifications. In case of success, returns 4.

Write the given QoS instance in one byte. In case of success, returns 1.

Write the given ReasonCodein one byte, returning 1 in case of success.

Write the given u16 according to MQTT5 Two Byte Integer specifications. In case of success, returns 2.

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 the given u32 into writer according to MQTT5 Variable Byte Integer specifications, returning the number of bytes written (1, 2, 3 or 4) in case of success.