Skip to main content

Module codec_envelope

Module codec_envelope 

Source
Expand description

Self-describing envelope used by quantization codecs that persist their calibrated parameters (BBQ, RaBitQ, …).

Wire layout: magic (5 bytes) + version (1 byte) + MessagePack body produced by zerompk. Codecs choose their own 5-byte magic (e.g. b"NDBBQ", b"NDRBQ") so a mismatched buffer fails fast with a typed CodecError instead of an opaque MessagePack decode error.

Constants§

HEADER_LEN
Total length of the envelope header (magic + version).
MAGIC_LEN
Length of the magic prefix.

Functions§

decode
Validate the envelope header and deserialize the body into T.
encode
Serialize value into a versioned, magic-tagged byte buffer.
peek_version
Read the version byte without decoding the body. Returns None if the buffer is too short or the magic does not match.