import type { BitMask, UTF8StringPair } from "./types.ts"; import type { PropsByPacketSetType } from "./Properties.ts"; import type { PacketType } from "./PacketType.ts"; import type { ReasonCode } from "./ReasonCode.ts"; /** * Checks if a specific bit flag is set in a byte using a bitmask * @param byte - The byte to check * @param mask - The bitmask to apply * @returns True if the flag is set, false otherwise */ export declare function booleanFlag(byte: number, mask: BitMask): boolean; /** * Checks if a buffer is empty, throws error if not empty * @param buf - The buffer to check * @throws {DecoderError} If buffer is not empty */ export declare function isEmptyBuf(buf: Uint8Array): void; /** * Checks if flags are empty (zero), throws error if not * @param flags - The flags value to check * @throws {DecoderError} If flags are not zero */ export declare function hasEmptyFlags(flags: number): void; /** * Custom error class for decoder errors */ export declare class DecoderError extends Error { constructor(message: string); } /** * Decoder class for parsing MQTT packets */ export declare class Decoder { private packetType; private buf; private pos; private len; /** * Creates a new Decoder instance * @param buf - The buffer to decode * @param pos - Starting position in the buffer (default: 0) */ constructor(packetType: PacketType, buf: Uint8Array, pos?: number); /** * Checks if the current position is valid * @param pos - Position to check * @throws {DecoderError} If position exceeds buffer length */ checkpos(pos: number): void; /** * Gets a single byte from the buffer * @returns The byte value */ getByte(): number; /** * Gets a 16-bit integer from the buffer * @returns The 16-bit integer value */ getInt16(): number; /** * Gets a 4 byte integer from the buffer (for v5) * @returns The 32 bit integer value */ getInt32(): number; /** * Gets a variable byte integer from the buffer (for v5) * its like the length decoder in length.ts but this one works directly on the buffer * @returns The decoded variable byte integer * @throws {DecoderError} If malformed variable byte integer */ getVariableByteInteger(): number; /** * Gets a byte array from the buffer * @returns A subarray of the buffer */ getByteArray(): Uint8Array; /** * Gets a UTF-8 string from the buffer * @returns The decoded UTF-8 string */ getUTF8String(): string; /** * Gets a UTF-8 string pair from the buffer (for v5) * @returns The decoded UTF-8 pair as [name,value] */ getUTF8StringPair(): UTF8StringPair; /** * Gets the remaining bytes from the current position to the end * @returns The remaining bytes as a subarray */ getRemainder(): Uint8Array; /** * Gets a single property * @param id * @returns */ private getProperty; /** * Gets all properties from the buffer * and validates if they are allowed for this type of packet * @param propertySetType * @returns * @throws {DecoderError} If properties are invalid */ getProperties(propertySetType: T): PropsByPacketSetType[T]; /** * Gets a reason code from the buffer * @returns The decoded reason code * @throws {DecoderError} If reason code is invalid */ geReasonCode(): ReasonCode; /** * Checks if decoder has reached the end of the buffer * @returns True if at end, false otherwise */ atEnd(): boolean; /** * Checks if decoding is complete * @returns True if complete * @throws {DecoderError} If packet is too long */ done(): boolean; } //# sourceMappingURL=decoder.d.ts.map