Expand description
On-disk codec registry for Value.
This module is the single source of truth for the byte layout
of every Value variant. Adding a new variant means:
- Add the variant to
Value. - Add the matching
DataTypetag (the on-disk type byte). - Add an arm to
encodeanddecodein this file.
That’s it — no other file needs to learn the layout. The inherent
Value::to_bytes / Value::from_bytes methods stay as the
public API, but they only delegate here.
§Why a registry
Before this module the encode / decode arms lived inside
types.rs, mixed with display / coercion / hashing logic. A
parallel value_type_tag helper in storage::query carried a
third numbering scheme. The result was that every new variant
required edits in three or more places and the tag spaces were
free to drift.
With the registry there is exactly one mapping
Value <-> on-disk bytes. The wire protocol keeps its own,
independent VAL_* tag space (see wire/protocol.rs); the two
were never identical and any future unification is out of scope.
§On-disk format
Bytes are unchanged versus the previous in-place implementation.
The pinned-byte regression test [tests::pinned_bytes] guards
the layout for the canonical variants (Null, Integer, Text, Bool,
Blob).
Functions§
- decode
- Decode a single value from
data, returning the value and the number of bytes consumed. - encode
- Encode a value into
out, appending its on-disk byte sequence. - type_
for_ tag - Reverse lookup for
type_tag. ReturnsNonefor unknown bytes;Some(DataType::Nullable)for the dedicated null marker0. - type_
tag - On-disk tag byte for a value.