TypeStructureDescriptor¶
- class dsviper.TypeStructureDescriptor(name, *, documentation=None)¶
Bases:
objectDescribes the fields a struct will be created with.
Definitions.create_structure() turns the descriptor into a TypeStructure.
- add_field(field_name: str, type_or_value: _DefaultValues, documentation: str | None = None) None¶
Add a field called field_name to the struct being described.
type_or_value is either the field type, or a value whose type it takes. documentation is carried onto the field.
- description() str¶
Return the type spelled out: its fields, then its name.
It reads {}:Name while no field has been added - a shape create_structure refuses, a struct requiring at least one field.
- documentation() str¶
Return the documentation the struct will be created with, empty when none was given.
- fields() list[TypeStructureField]¶
Return the list of fields.
- name() str¶
Return the name the struct will be created under.