TypeStructure

class dsviper.TypeStructure

Bases: Type

A struct type.

Note: Not directly instantiable.

static cast(type: Type) → TypeStructure

Return a type struct or raise.

check(field_name: str) → TypeStructureField

Return the field called field_name, or raise if the struct has none.

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

Return the struct spelled out: its fields, then its name.

Each field appears as name:type with its default when it has one, in braces. namespace qualifies the names.

documentation() → str

Return the documentation the type was created with, empty when none was given.

fields() → list[TypeStructureField]

Return the list of fields.

is_compact() → bool

Return True if every field is a bool or a number.

A document tree shows such a structure on one line. Compact is not sized: a vec or a uuid field has a fixed size and is not compact.

query(field_name: str) → TypeStructureField | None

Return the field called field_name, or None if the struct has none.

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

Return the name the type was declared under, qualified against namespace - the global namespace when it is None.

runtime_id() → ValueUUId

Return the uuid identifying this type.

It is computed from what the type is, so the same declaration yields the same id in any Definitions. Definitions says what each kind is computed from.

type_code() → str

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

type_name() → TypeName

Return the TypeName: the namespace and the name the type was declared under.