Decodes one complete MQTT control packet from a buffer.
Reads the fixed header, then dispatches on the packet type to parse the variable header and
payload, returning a DecodedPacket discriminated on type. The buffer must hold exactly
one full packet starting at offset 0; callers framing a stream should use
decodeRemainingLength to size each packet before slicing it out. A CONNACK is decoded
loosely so a v5 broker's extra trailing bytes (properties) are ignored rather than rejected.
Decodes one complete MQTT control packet from a buffer.
Reads the fixed header, then dispatches on the packet type to parse the variable header and payload, returning a DecodedPacket discriminated on
type. The buffer must hold exactly one full packet starting at offset 0; callers framing a stream should use decodeRemainingLength to size each packet before slicing it out. A CONNACK is decoded loosely so a v5 broker's extra trailing bytes (properties) are ignored rather than rejected.