import { ReadStatSeek } from "./types.js"; export interface IoContext { /** Read up to `nbyte` bytes at the current cursor; returns actual bytes (may be shorter at EOF). */ read(nbyte: number): Uint8Array; /** Move the cursor. Returns the new absolute offset, or -1 on error. */ seek(offset: number, whence: ReadStatSeek): number; /** Current absolute offset. */ tell(): number; /** Total size in bytes. */ size(): number; } /** In-memory IO context backed by a Uint8Array. */ export declare class BufferIoContext implements IoContext { private data; private cursor; constructor(data: Uint8Array); read(nbyte: number): Uint8Array; seek(offset: number, whence: ReadStatSeek): number; tell(): number; size(): number; } /** * Read exactly `nbyte` bytes or throw. Mirrors the ubiquitous * `if (io->read(...) < len) { retval = READSTAT_ERROR_READ; }` pattern. * Returns a fresh copy so callers may retain it safely. */ export declare function ioReadExact(io: IoContext, nbyte: number): Uint8Array; export declare class IoReadError extends Error { constructor(wanted: number, got: number); }