/** * @packageDocumentation Variant discriminated-union type for complex metadata properties. */ import { ByteVector } from "../byteVector.js"; /** Discriminant tag for the {@link Variant} union. */ export declare enum VariantType { /** No value (null/undefined equivalent). */ Void = 0, /** Boolean value. */ Bool = 1, /** 32-bit signed integer. */ Int = 2, /** 32-bit unsigned integer. */ UInt = 3, /** 64-bit signed integer (`bigint`). */ LongLong = 4, /** 64-bit unsigned integer (`bigint`). */ ULongLong = 5, /** IEEE-754 double-precision float. */ Double = 6, /** UTF-16 string. */ String = 7, /** Ordered list of strings. */ StringList = 8, /** Raw binary data. */ ByteVector = 9, /** Ordered list of raw binary buffers. */ ByteVectorList = 10, /** Ordered list of {@link Variant} values. */ VariantList = 11, /** String-keyed map of {@link Variant} values. */ VariantMap = 12 } /** A string-keyed map whose values are {@link Variant} instances. */ export type VariantMap = Map; /** An ordered list of {@link Variant} instances. */ export type VariantList = Variant[]; /** * A discriminated-union value that can hold any of the types enumerated * by VariantType. Used for complex metadata properties. */ export declare class Variant { /** Active type discriminant. */ private _type; /** The stored value; its runtime type matches `_type`. */ private _value; /** * @param type - Discriminant identifying the stored type. * @param value - The actual value to store. */ private constructor(); /** Creates a void (empty) Variant. */ static fromVoid(): Variant; /** * @param v - Boolean value to store. */ static fromBool(v: boolean): Variant; /** * Stores `v` truncated to a 32-bit signed integer. * * @param v - Number to store as a signed 32-bit integer. */ static fromInt(v: number): Variant; /** * @param v - Number to store as an unsigned 32-bit integer. */ static fromUInt(v: number): Variant; /** * @param v - `bigint` to store as a signed 64-bit integer. */ static fromLongLong(v: bigint): Variant; /** * @param v - `bigint` to store as an unsigned 64-bit integer. */ static fromULongLong(v: bigint): Variant; /** * @param v - Number to store as a double-precision float. */ static fromDouble(v: number): Variant; /** * @param v - String to store. */ static fromString(v: string): Variant; /** * Stores a copy of the provided string array. * * @param v - String list to store. */ static fromStringList(v: string[]): Variant; /** * Stores a copy of the provided {@link ByteVector}. * * @param v - Binary data to store. */ static fromByteVector(v: ByteVector): Variant; /** * Stores copies of each {@link ByteVector} in the list. * * @param v - List of binary buffers to store. */ static fromByteVectorList(v: ByteVector[]): Variant; /** * Stores a shallow copy of the provided {@link VariantList}. * * @param v - List of Variant values to store. */ static fromList(v: VariantList): Variant; /** * Stores a shallow copy of the provided {@link VariantMap}. * * @param v - Map of Variant values to store. */ static fromMap(v: VariantMap): Variant; /** Returns the active {@link VariantType} discriminant. */ type(): VariantType; /** Returns `true` when the variant holds no value (`Void`). */ isEmpty(): boolean; /** * Returns the stored value as a boolean. * Returns `false` if the type is not {@link VariantType.Bool}. */ toBool(): boolean; /** * Returns the stored value as a JavaScript number. * Numeric types are coerced; all other types return `0`. */ toInt(): number; /** * Returns the stored value as a double-precision float. * Numeric types are coerced; all other types return `0`. */ toDouble(): number; /** * Returns the stored value as a `bigint`. * Integer `bigint` types are returned directly; JS number types are * promoted via `BigInt()`; all other types return `0n`. */ toLongLong(): bigint; /** * Returns the stored value as a string. * Scalar types are stringified; non-scalar types return `""`. */ toString(): string; /** * Returns the stored value as a string array. * A single `String` value is wrapped in a one-element array. * All other types return `[]`. */ toStringList(): string[]; /** * Returns a copy of the stored {@link ByteVector}. * Returns an empty `ByteVector` for all other types. */ toByteVector(): ByteVector; /** * Returns copies of the stored {@link ByteVector} list. * A single `ByteVector` value is wrapped in a one-element array. * All other types return `[]`. */ toByteVectorList(): ByteVector[]; /** * Returns a shallow copy of the stored {@link VariantList}. * Returns `[]` for all other types. */ toList(): VariantList; /** * Returns a shallow copy of the stored {@link VariantMap}. * Returns an empty `Map` for all other types. */ toMap(): VariantMap; } //# sourceMappingURL=variant.d.ts.map