Data & serialization¶
The wire records A11 moves — chunks, fragments, node references, and wire messages — and the registry that turns Python objects into chunks and back.
Chunk¶
a11.data.types.Chunk
¶
A unit of node data with optional metadata and ref.
Create a chunk from optional metadata, a ref, and payload data.
a11.data.types.ChunkMetadata
¶
Metadata describing a chunk of node data.
Create chunk metadata from a MIME type, timestamp, and attributes.
attributes
property
writable
¶
Byte-string attribute map attached to the chunk.
from_msgpack
staticmethod
¶
from_msgpack(data: Any) -> ChunkMetadata
Deserialize a value from MessagePack bytes.
model_construct
classmethod
¶
Construct a native value from trusted field values.
Native records retain C++ invariants. This validates input rather than creating an invalid object.
get_attribute
¶
Return the attribute bytes for a key, raising if it is absent.
Fragments & references¶
a11.data.types.NodeFragment
¶
A fragment of a logical node carrying a Chunk or NodeRef.
Create a node fragment from Chunk/NodeRef data and framing fields.
from_msgpack
staticmethod
¶
from_msgpack(data: Any) -> NodeFragment
Deserialize a value from MessagePack bytes.
model_construct
classmethod
¶
Construct a native value from trusted field values.
Native records retain C++ invariants. This validates input rather than creating an invalid object.
a11.data.types.NodeRef
¶
Reference to a byte range of another logical node.
Create a node reference from an id, byte offset, and length.
Messages¶
a11.data.types.Port
¶
A named input or output port of an action.
Create a port from a name and node id.
a11.data.types.ActionMessage
¶
A message invoking a named action with input and output ports.
Create an action message from id, name, ports, and headers.
from_msgpack
staticmethod
¶
from_msgpack(data: Any) -> ActionMessage
Deserialize a value from MessagePack bytes.
model_construct
classmethod
¶
Construct a native value from trusted field values.
Native records retain C++ invariants. This validates input rather than creating an invalid object.
a11.data.types.WireMessage
¶
A wire-format message bundling node fragments and actions.
Create a wire message from node fragments, actions, and headers.
actions
property
writable
¶
Action messages carried by the message.
node_fragments
property
writable
¶
Node fragments carried by the message.
from_json
staticmethod
¶
from_json(value: str) -> WireMessage
Deserialize a message from its JSON wire encoding.
from_msgpack
staticmethod
¶
from_msgpack(data: Any) -> WireMessage
Deserialize a value from MessagePack bytes.
model_construct
classmethod
¶
Construct a native value from trusted field values.
Native records retain C++ invariants. This validates input rather than creating an invalid object.
Serialization¶
a11.data.serialization.SerializationRegistry
¶
A registry of serializers and deserializers indexed by type and MIME.
New registries are empty. Pass register_defaults=True or call
register_defaults to install the built-in JSON and MessagePack
codecs. The process-wide registry returned by
get_global_serialization_registry already contains them.
set_type_tag
¶
Pin the wire tag used to identify obj_type in serialized data.
Overrides the default fully-qualified name. Use this to keep a short, stable tag for a type (for example to preserve an existing wire format) or to give two like-named types deterministic, distinct identifiers.
register_serializer
¶
Register serializer(obj) for a type and exact media type.
register_deserializer
¶
register_deserializer(obj_type: type, mimetype: str, deserializer: DeserializerFn, *, receives_chunk: bool | None = None) -> None
Register a data deserializer for a type and exact media type.
A deserializer may accept either data or data, obj_type. A
callback whose first argument is named chunk (or is annotated as a
Chunk) receives the complete chunk instead of chunk.data.
receives_chunk can be used to select that behavior explicitly.
register
¶
register(obj_type: type, mimetype: str, serializer: SerializerFn, deserializer: DeserializerFn, *, receives_chunk: bool | None = None) -> None
Atomically register a serializer/deserializer pair.
register_defaults
¶
Install the standard JSON and MessagePack registrations.
to_chunk
¶
to_chunk(obj: Any, mimetype: str = '') -> Chunk
Serialize obj into a chunk.
If mimetype is empty, the closest registered Python type wins and
registration order chooses its preferred representation. An explicit
MIME value can be exact or contain * wildcards. Returned chunks
always have an exact MIME type and a stable Python type identifier.
from_chunk
¶
from_chunk(chunk: Chunk, mimetype_patterns: str | Sequence[str] = '', obj_type: type | None = None) -> Any
Deserialize chunk using the first matching MIME selector.
Selectors are matched in order against the chunk's MIME type and may
contain wildcards. If the chunk has no MIME metadata, a supplied exact
selector acts as the representation. A requested obj_type uses an
exact registration first and then registrations for its superclasses.