UNPKG

1.83 kBTypeScriptView Raw
1/**
2 * A buffer maintaining a write position capable of writing primitive values
3 */
4export interface WriteBuffer {
5 writeUint8(byte: number): this;
6 writeUint16(value: number): this;
7 writeUint32(value: number): this;
8 writeString(value: string): this;
9 writeBytes(value: Uint8Array): this;
10 writeNumber(value: number): this;
11 writeLength(value: number): this;
12 /**
13 * Makes any writes to the buffer permanent, for example by sending the writes over a channel.
14 * You must obtain a new write buffer after committing
15 */
16 commit(): void;
17}
18export declare class ForwardingWriteBuffer implements WriteBuffer {
19 protected readonly underlying: WriteBuffer;
20 constructor(underlying: WriteBuffer);
21 writeUint8(byte: number): this;
22 writeUint16(value: number): this;
23 writeUint32(value: number): this;
24 writeLength(value: number): this;
25 writeString(value: string): this;
26 writeBytes(value: Uint8Array): this;
27 writeNumber(value: number): this;
28 commit(): void;
29}
30/**
31 * A buffer maintaining a read position in a buffer containing a received message capable of
32 * reading primitive values.
33 */
34export interface ReadBuffer {
35 readUint8(): number;
36 readUint16(): number;
37 readUint32(): number;
38 readString(): string;
39 readNumber(): number;
40 readLength(): number;
41 readBytes(): Uint8Array;
42 /**
43 * Returns a new read buffer whose starting read position is the current read position of this buffer.
44 * This is useful to create read buffers sub messages.
45 * (e.g. when using a multiplexer the beginning of the message might contain some protocol overhead which should not be part
46 * of the message reader that is sent to the target channel)
47 */
48 sliceAtReadPosition(): ReadBuffer;
49}
50//# sourceMappingURL=message-buffer.d.ts.map
\No newline at end of file