ValueVariant

class dsviper.ValueVariant(type_variant, initial_value)

Bases: Value

A value of type variant<T0, …>. Seamless with a Python object compatible with the variant’s types.

Or use Value.create(type_variant [, initial_value]).

static cast(value: Value | _OutputValues) → ValueVariant

Return value as a variant<T0, …>, or raise if it is not one.

copy() → ValueVariant

Return a deep copy.

description(*, namespace: NameSpace | None = None) → str

Return the description of the value it holds, which carries its own type and qualifies it against namespace.

hash() → int

Return the hash value.

representation() → str

Return the value written out: whatever the value it holds returns.

type() → Type

Return the Type this value is an instance of.

type_code() → str

Return the code naming this kind of value, such as “int32”, “struct” or “vector”.

type_variant() → TypeVariant

Return the type variant<T0, …>.

unwrap(*, encoded: Literal[True] = True) → _OutputValues

Return the value or raise.

encoded=False returns a Value rather than a native object.

wrap(value: _InputValues, type: Type | None = None) → None

Store value in the variant, as type when the variant admits more than one that fits.