yggdrasil.pickle.ser.header¶
header ¶
Header ¶
Header(
tag: int,
codec: int,
size: int,
meta_size: int,
start: int,
metadata: Metadata = None,
*,
_meta_blob: bytes | None = None
)
Binary header for a serialized payload.
Layout
tag:u16 codec:u16 size:u32 meta_size:u32 metadata:meta_size bytes payload:size bytes
build
classmethod
¶
build(
*,
tag: int,
codec: int,
size: int,
metadata: Mapping[bytes, bytes] | None = None,
start: int = 0
) -> "Header"
Build a header from semantic fields.
read_from
classmethod
¶
Parse a header from a buffer without materializing the payload.
payload_view ¶
Return a buffer over the payload sub-range [start, start+size).
A :class:_ScratchBuf slices in place (its own zero-copy view); a
yggdrasil :class:IO is read directly (pread) into a fresh
:class:_ScratchBuf — the pickle module's lightweight read surface —
which is exactly what the bounded IO.view did before.
write_to ¶
write_to(
data: bytes | bytearray | memoryview,
*,
buffer: "IO | TypingIO[bytes] | None" = None
) -> "IO | TypingIO[bytes]"
Write header + payload into a buffer and return that buffer.
Streams via the universal :class:IO[bytes].write method so a
stdlib io.BytesIO or any open file handle works as a sink —
not just the yggdrasil :class:IO. Avoids the extra
to_bytes() materialization that previous shapes incurred.