import type { UTF8StringPair } from "./types.ts"; import type { PropertySetType, PropsByPacketSetType } from "./Properties.ts"; import type { PacketType } from "./PacketType.ts"; import type { ReasonCode } from "./ReasonCode.ts"; /** * Custom error class for encoding operations */ export declare class EncoderError extends Error { constructor(message: string); } export declare class Encoder { /** Internal bufferlist to store items */ private buffers; /** Number of bytes in the buffer */ private numBytes; /** Packet type */ private packetType; /** marker to rewind to */ private marker; /** * Creates a new Encoder instance */ constructor(packetType: PacketType); encodedSize(): number; setMarker(): void; rewindToMarker(): void; /** * @param value */ addArray(value: number[] | Uint8Array): this; /** * Adds a single byte to the buffer * @param value - Byte value to add (0-255) * @returns The encoder instance for chaining */ setByte(value: number): this; /** * Adds a 16-bit integer to the buffer in big-endian format * @param value - 16-bit integer value to add * @returns The encoder instance for chaining */ setInt16(value: number): this; /** * adds a 4 byte integer from the buffer (for v5) * @param value - 32-bit integer to encode and add * @returns The encoder instance for chaining */ setInt32(value: number): this; /** * adds a variable byte integer to the buffer (for v5) * @param value - integer to encode and add * @returns The encoder instance for chaining */ setVariableByteInteger(value: number): this; /** * Adds a byte array to the buffer with length prefix * @param value - Byte array to add * @throws {EncoderError} If array length exceeds 0xffff bytes * @returns The encoder instance for chaining */ setByteArray(value: Uint8Array): this; /** * Adds a UTF-8 encoded string to the buffer with length prefix * @param value - String to encode and add * @returns The encoder instance for chaining */ setUtf8String(value: string): this; /** * Adds a UTF-8 string pair from the buffer (for v5) * @param stringPair - UTF8StringPair * @returns The encoder instance for chaining */ setUtf8StringPair([name, value]: UTF8StringPair): this; /** * Adds remaining bytes to the buffer without modification * @param value - Array of bytes to add * @returns The encoder instance for chaining */ setRemainder(value: Uint8Array | number[]): this; /** * add lenght and buffers from this * @param encoder - the encoder to add it to */ addToEncoder(encoder: Encoder): void; /** * Encode a single property * @param id - the id of the property * @param value the value of the property * @returns */ private setProperty; /** * Encode a set of properties respecting potential size limits * @param props - the properties to encode * @param propertySetType - the type of packet to encode for * @param maximumPacketSize - the maximum packet size to be consumed by properties */ setProperties(props: PropsByPacketSetType[T], propertySetType: PropertySetType, maximumPacketSize: number): void; seReasonCode(reasonCode: ReasonCode): this; /** * Returns the final encoded buffer * @returns Array containing all encoded bytes */ done(flags: number): Uint8Array; } //# sourceMappingURL=encoder.d.ts.map