import { ArrayType } from './array.js'; import type { StructConstructor, StructInstance } from './structs.shared.js'; import { type Type, type Value } from './types.js'; export interface FieldOptions { bigEndian?: boolean; align?: number; typeName?: string; countedBy?: string | ((instance: StructInstance) => number); } export interface FieldConfig extends FieldOptions { type: T; } export interface Field = Type> { name: string; type: T; /** The static offset of the field */ offset: number; alignment: number; countedBy?: string | ((instance: StructInstance) => number); /** A C-style type/name declaration string, used for diagnostics */ readonly decl: string; /** Whether the field is little endian */ littleEndian: boolean; } export type FieldConfigInit = FieldConfig | T | FieldBuilder; export type FieldValue = Init extends StructConstructor ? InstanceType : Init extends Type ? Value : Init extends FieldConfigInit ? Value : never; export declare function parseFieldConfig(init: FieldConfigInit): FieldConfig; type _ToArray = { (length: number): FieldBuilder, Config>; }; export interface FieldBuilder extends _ToArray { } export declare class FieldBuilder { readonly type: T; private readonly init; constructor(type: T, init: Config); /** * Align the field to a given byte boundary. */ align(align: N): FieldBuilder; countedBy(field: K): FieldBuilder; countedBy(fn: (instance: StructInstance) => number): FieldBuilder; /** * Set the field to big-endian. */ bigEndian(): FieldBuilder; toInit(): FieldConfig & Config; /** * Override the typescript type of the field's value, for example to override `number` with an enum type. * This does not have any runtime effects. */ $type(): FieldBuilder, Config>; } export declare function array(type: T, length?: number): FieldBuilder>; export {};