@seriousme/opifex
Version:
MQTT client & server for Deno & NodeJS
69 lines • 2.22 kB
TypeScript
import type { Topic, TopicFilter } from "./types.ts";
/**
* Custom error class for encoding operations
*/
export declare class EncoderError extends Error {
constructor(message: string);
}
/**
* Encoder class for MQTT packet encoding
*/
export declare class Encoder {
/** Internal buffer to store encoded bytes */
private buffer;
/**
* Creates a new Encoder instance
*/
constructor();
/**
* 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 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 an MQTT topic string to the buffer
* @param value - Topic string to add
* @throws {EncoderError} If topic is invalid
* @returns The encoder instance for chaining
*/
setTopic(value: Topic): this;
/**
* Adds an MQTT topic filter string to the buffer
* @param value - Topic filter string to add
* @throws {EncoderError} If topic filter is invalid
* @returns The encoder instance for chaining
*/
setTopicFilter(value: TopicFilter): 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;
/**
* Returns the final encoded buffer
* @returns Array containing all encoded bytes
*/
done(): number[];
}
//# sourceMappingURL=encoder.d.ts.map