ValueStructure

class dsviper.ValueStructure

Bases: Value

A value of type struct. Seamless with a Python dict[str, object].

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

A field is written as an attribute - doc.name = value - or with set(field_name, value), and read either way. A name the struct does not declare is refused.

This constructor builds a new container over the same elements, so only a mutation inside an element shows through.

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

Return the value of the field called field_name.

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

static cast(value: Value | _OutputValues) → ValueStructure

Return value as a struct, or raise if it is not one.

copy() → ValueStructure

Return a deep copy.

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

Return the value written out, then its type, as <value>:<type>.

namespace qualifies the type name; representation() gives the value alone.

hash() → int

Return the hash value.

representation() → str

Return the value written out: the fields between braces, comma separated.

set(field_name: str, value: _InputValues)

Write value into the field called field_name.

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_structure() → TypeStructure

Return the type struct.