import type { Expand } from 'utilium'; import type { Field, FieldConfigInit, FieldValue } from './fields.js'; import { type Type } from './types.js'; export type StructInstance = ArrayBufferView & { constructor: StructConstructor; } & T; export declare function isStructInstance(arg: unknown): arg is StructInstance; export interface StructType extends Type { /** @hidden breaks typedoc in dependencies */ readonly fields: FieldOf[]; readonly alignment: number; readonly isUnion: boolean; readonly isDynamic?: boolean; } export interface StructConstructor extends StructType { prototype: StructInstance; new (buffer?: TArrayBuffer, byteOffset?: number, byteLength?: number): Expand>; } export type InstanceOf> = T extends StructConstructor ? U & InstanceType & { constructor: T; } : never; export interface FieldOf extends Field> { name: keyof T & string; countedBy?: (keyof T & string) | ((instance: StructInstance) => number); } export declare function isStructConstructor(arg: unknown): arg is StructConstructor; export type StructValue> = Expand<{ -readonly [K in keyof T]: FieldValue; }>; export type ExtendStruct, T extends Record> = Base extends StructConstructor ? Expand<{ -readonly [K in keyof T | keyof U]: K extends keyof T ? FieldValue : K extends keyof U ? U[K] : never; }> : never; /** * Gets the dynamic size in bytes of a struct instance. * This *does not* include the static size of the struct. */ export declare function dynamicStructSize(instance: StructInstance): number;