Encodes an MQTT remaining-length value as a 1-4 byte varint.
MQTT uses a base-128 varint with the high bit of each byte signalling continuation, capping the
value at MAX_REMAINING_LENGTH. This is the length prefix on every fixed header and is
the most error-prone part of the wire format, so it lives in its own well-tested function.
Encodes an MQTT remaining-length value as a 1-4 byte varint.
MQTT uses a base-128 varint with the high bit of each byte signalling continuation, capping the value at MAX_REMAINING_LENGTH. This is the length prefix on every fixed header and is the most error-prone part of the wire format, so it lives in its own well-tested function.