typia
Version:
Superfast runtime validators with only one line
62 lines (61 loc) • 2.27 kB
TypeScript
import { ProtobufWire } from "@typia/interface";
export declare class _ProtobufReader {
/** Read buffer */
private buf;
/** Read buffer pointer. */
private ptr;
/** DataView for buffer. */
private view;
/** Current length-delimited boundary. */
private end;
constructor(buf: Uint8Array);
index(): number;
size(): number;
uint32(): number;
int32(): number;
sint32(): number;
uint64(): bigint;
int64(): bigint;
sint64(): bigint;
bool(): boolean;
float(): number;
double(): number;
bytes(): Uint8Array;
string(): string;
fork(): number;
close(previous: number): void;
/** Advance by exactly `length` bytes, for every length including zero. */
skip(length: number): void;
/**
* Advance by exactly one varint, which carries no length prefix.
*
* A varint terminates at its first byte without the continuation bit, and may
* occupy no more than {@link VARINT_MAX_BYTES}. Its tenth byte is bounded
* twice over, by {@link lastVarintByte}: it may neither continue into an
* eleventh byte nor carry payload above bit 63. Skipping is where that is
* easiest to get wrong, because this path discards the bytes it reads and so
* never notices a value it could not have represented. Relaxing either bound
* here would accept a varint that `varint32` and `varint64` reject, making
* the limit depend on which method happens to consume the value.
*/
skipVarint(): void;
skipType(wireType: ProtobufWire): void;
private varint32;
private varint64;
/**
* Read the only byte whose varint payload is limited to bit 63.
*
* Two distinct faults meet on this byte, and each is named for what it is. A
* continuation bit means the varint would occupy an eleventh byte, which no
* 64-bit value can reach. Any other payload bit means the varint terminates
* within its ten bytes but carries a value bit above 63. Reporting the second
* as a length fault would tell the caller something untrue about a payload
* that is exactly ten bytes long.
*/
private lastVarintByte;
private u8;
private u8n;
private take;
private atomic;
private validate;
}