struct
struct
#
Struct — named fields. Subclass Struct; the annotations are the fields.
A field named with a leading _ is hidden on disk (_metadata → .metadata).
A loaded struct is read-only; .clone() gives an in-memory copy that can change.
Struct
#
Bases: CGType
A type with named fields; each subclass is a dataclass over its annotations.
Source code in capturegraph-lib/capturegraph/types/containers/struct.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
__init_subclass__(**kwargs)
#
Turn cls into a dataclass over its annotated CGType fields.
Source code in capturegraph-lib/capturegraph/types/containers/struct.py
__setattr__(name, value)
#
Assign a field.
Raises:
| Type | Description |
|---|---|
TypeError
|
If this struct was loaded from disk. |
Source code in capturegraph-lib/capturegraph/types/containers/struct.py
clone()
#
An in-memory copy that can change, its containers copied and its scalars shared.
Source code in capturegraph-lib/capturegraph/types/containers/struct.py
load(base)
classmethod
#
The struct stored at base, one entry per field; an absent field is Missing.
A field with nothing on disk (an optional capture that never happened)
is Missing with a FileNotFoundError reason; a field stored as a
marker carries the reason the marker holds.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If |
Source code in capturegraph-lib/capturegraph/types/containers/struct.py
schema()
classmethod
#
This struct's wire form: each field's schema, tagged "struct".
Source code in capturegraph-lib/capturegraph/types/containers/struct.py
store(base, value)
classmethod
#
Write each field of value under base, named for the field.
value is an instance of this struct or of any struct with the same
schema — one defined by a re-executed module, say. A Missing field
is written as the marker <field>.cg-missing holding its reason, and
loads back as Missing.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in capturegraph-lib/capturegraph/types/containers/struct.py
on_disk(field_name)
#
The on-disk entry name for a struct field (_metadata → .metadata).
struct_fields(struct_or_type)
#
The declared fields of a Struct value or type, name → type, as a fresh dict.
Raises:
| Type | Description |
|---|---|
TypeError
|
If the argument is not a |