[][src]Crate sage_mqtt

sage_mqtt is a an encoding/decoding library for MQTT 5.0 protocol. The library consists in pivot types, such as UTF8String that can be written to and read from a stream as well as converted to standard Rust types.

Structs

BinaryData

Binary Data is represented by a Two Byte Integer length which indicates the number of data bytes, followed by that number of bytes. Thus, the length of Binary Data is limited to the range of 0 to 65,535 Bytes. This type can be converted from and to Vec<u8>.

Bits

Bits in a byte are labelled 7 to 0. Bit number 7 is the most significant bit. This type can be converted from and to u8.

Broker
Byte
Connect

The Connect control packet is used to open a connection

FourByteInteger

Four bytes data values are 32-bits unsigned integer represented in big-endian. That means the most significant byte (MSB) is presented first on the stream. This type can be converted from u8, u16 and u32 and to u32 and u64.

TwoByteInteger

Two bytes data values are 16-bits unsigned integer represented in big-endian. That means the most significant byte (MSB) is presented first on the stream. This type can be converted from u8 and u16 and to u8, u16 and u32.

UTF8String

Text fields in an MQTT paquet are described in UTF-8. Each string in the stream is prefixed with a two-byte size information with MSB first. Because of that, a string cannot be longer that 65,535 bytes. This type can be converted from and to String.

VariableByteInteger

The Variable Byte Integer is encoded using an encoding scheme which uses a single byte for values up to 127. Larger values are handled as follows. The least significant seven bits of each byte encode the data, and the most significant bit is used to indicate whether there are bytes following in the representation. Thus, each byte encodes 128 values and a "continuation bit". The maximum number of bytes in the Variable Byte Integer field is four.

Enums

ControlPacket
Error
QoS
ReasonCode

Traits

Decode

The Decode trait is implemented for any type that can be read from a stream.

Encode

The Encode trait describes how to write a type into an MQTT stream.

Type Definitions

Result