[][src]Module sage_mqtt::codec

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 being 0x00 for false or 0x01 for false. Other values are considered incorrect. In case of success, returns an bool

read_byte

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

read_control_packet_type

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

read_four_byte_integer

Read the given reader for an u32, 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 an u16, 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 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_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 being 0x00 for false or 0x01 for false. Other values are considered incorrect. In case of success, returns 1

write_byte

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

write_control_packet_type

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

write_four_byte_integer

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

write_qos

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

write_reason_code

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

write_two_byte_integer

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

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