API Reference / @gtkx/runtime / fromVariant
Function: fromVariant()
Call Signature
fromVariant<
S>(typeString,variant):ParsedValue<S>
Defined in: packages/runtime/src/variant.ts:514
Unpacks a GLib.Variant, reversing toVariant.
String-keyed dictionaries become records; other dictionaries become Maps. Arrays and tuples become arrays, ay becomes Uint8Array, and maybes become their value or null. Nested variants stay as GLib.Variant unless recursive is set, which unwraps them fully.
A literal typeString determines the return type. When omitted, the variant's own type is used and the result is unknown.
Type Parameters
S
S extends string
Parameters
typeString
S
One complete GVariant type matching the variant.
variant
Variant
Variant to unpack.
Returns
ParsedValue<S>
The unpacked value.
Throws
If the type string is not one complete GVariant type.
Call Signature
fromVariant<
S>(typeString,variant,options):ParsedValue<S>
Defined in: packages/runtime/src/variant.ts:525
Unpacks a GLib.Variant and every nested variant, typing the result from typeString.
Type Parameters
S
S extends string
Parameters
typeString
S
One complete GVariant type matching the variant.
variant
Variant
Variant to unpack.
options
Enables recursive unwrapping of nested variants.
Returns
ParsedValue<S>
The unpacked value with nested variants fully unwrapped.
Throws
If the type string is not one complete GVariant type.
Call Signature
fromVariant<
S>(typeString,variant,options):ParsedValue<S,Uint8Array<ArrayBufferLike>,Variant> |ParsedValue<S,Uint8Array<ArrayBufferLike>,unknown>
Defined in: packages/runtime/src/variant.ts:540
Unpacks a GLib.Variant with configurable recursive unwrapping.
Type Parameters
S
S extends string
Parameters
typeString
S
One complete GVariant type matching the variant.
variant
Variant
Variant to unpack.
options
Whether to unwrap nested variants recursively.
Returns
ParsedValue<S, Uint8Array<ArrayBufferLike>, Variant> | ParsedValue<S, Uint8Array<ArrayBufferLike>, unknown>
The unpacked value, typed according to typeString and the unwrapping options.
Throws
If the type string is not one complete GVariant type.
Call Signature
fromVariant(
variant,options?):unknown
Defined in: packages/runtime/src/variant.ts:553
Unpacks a GLib.Variant using its own type string.
Parameters
variant
Variant
Variant to unpack.
options?
Whether to unwrap nested variants recursively.
Returns
unknown
The unpacked value, typed as unknown because no type string was supplied.