VariableByteInt

Variable Byte Integer encoding/decoding per MQTT 5.0 §1.5.5.

Each byte encodes 7 data bits (bits 0-6) plus a continuation bit (bit 7). Maximum 4 bytes, maximum value 268,435,455.

Properties

Link copied to clipboard
const val MAX_VALUE: Int

Functions

Link copied to clipboard
fun decode(bytes: ByteArray, offset: Int = 0): VbiResult

Decode a Variable Byte Integer from the given bytes starting at offset.

Link copied to clipboard
fun encode(value: Int): ByteArray

Encode an integer as a Variable Byte Integer.