import type { Writer, Reader } from './io.ts'; export type PrimitiveKind = | 'u8' | 'u16' | 'u32' | 'i8' | 'i16' | 'i32' | 'u53' | 'i53' | 'u64' | 'i64' | 'f32' | 'f64' | 'bool' | 'str' | 'bytes'; export type TypedArrayKind = 'f32Array' | 'f64Array' | 'u8Array' | 'u16Array' | 'u32Array' | 'i32Array'; export interface PrimitiveSchema { readonly kind: K; readonly __t?: T; } export interface TypedArraySchema { readonly kind: K; readonly __t?: T; } export interface ArraySchema { readonly kind: 'array'; readonly elem: E; } export interface OptionalSchema { readonly kind: 'optional'; readonly elem: E; } export interface EnumSchema { readonly kind: 'enum'; readonly values: L; } export interface BitsetSchema { readonly kind: 'bitset'; readonly flags: L; } export interface TupleSchema { readonly kind: 'tuple'; readonly elems: E; } export interface ObjectSchema = Record> { readonly kind: 'object'; readonly name: string; readonly fields: F; } export interface UnionSchema< D extends string = string, V extends Record = Record, > { readonly kind: 'union'; readonly name: string; readonly discriminator: D; readonly variants: V; } export interface RefSchema { readonly kind: 'ref'; readonly thunk: () => S; } export interface CodecSchema { readonly kind: 'codec'; readonly encode: (w: Writer, v: T) => void; readonly decode: (r: Reader) => T; readonly __t?: T; } export type AnySchema = | PrimitiveSchema | TypedArraySchema | ArraySchema | OptionalSchema | EnumSchema | BitsetSchema | TupleSchema | ObjectSchema | UnionSchema | RefSchema | CodecSchema;