import { AssertState } from "./assert.js"; import { DecodeBuffer, EncodeBuffer } from "./buffer.js"; import { Metadata } from "./metadata.js"; export type Input = T extends Codec ? I : never; export type Output = T extends Codec ? O : never; export declare function createCodec(_codec: ThisType> & Pick, "_encode" | "_decode" | "_assert" | "_staticSize" | "_metadata">): Codec; type NoInfer = T extends infer U ? U : never; export declare function withMetadata(metadata: Metadata, NoInfer>, codec: Codec): Codec; declare const nodeCustomInspect: unique symbol; declare const denoCustomInspect: unique symbol; declare abstract class _Codec { private [nodeCustomInspect]; private [denoCustomInspect]; private _inspect; } export type AnyCodec = Codec; export type Encodec = Codec; export type Decodec = Codec; export declare abstract class Codec extends _Codec implements AnyCodec { /** A static estimation of the size, which may be an under- or over-estimate */ abstract _staticSize: number; /** Encodes the value into the supplied buffer, which should have at least `_staticSize` free byte. */ abstract _encode: (buffer: EncodeBuffer, value: I) => void; /** Decodes the value from the supplied buffer */ abstract _decode: (buffer: DecodeBuffer) => O; /** Asserts that the value is valid for this codec */ abstract _assert: (state: AssertState) => void; /** An array with metadata representing the construction of this codec */ abstract _metadata: Metadata; /** Encodes the value into a new Uint8Array (throws if async) */ encode(value: I): Uint8Array; /** Asynchronously encodes the value into a new Uint8Array */ encodeAsync(value: I): Promise; /** Decodes a value from the supplied Uint8Array */ decode(array: Uint8Array): O; /** Requires the codec to have an explicit type annotation; if it doesn't, use `$.assert` instead. */ assert(value: unknown): asserts value is I; } /** Asserts that the value is valid for the specified codec */ export declare function assert(codec: Codec, value: unknown): asserts value is I; export declare function is(codec: Codec, value: unknown): value is T; export {};