Module deserializer

Source
Expand description

Tagged-map msgpack deserializer that wraps [rmp_serde::Deserializer].

Mirrors crate::serializer::Serializer: each aggregate shape that the macro emits — named struct, multi-element tuple struct, sequence, tuple, map, option, newtype struct — is intercepted to translate integer wire tags back to the serde field/variant names the Visitor expects, via the TagRegistry.

The public entry point is msgpack_tagged_deserialize, which builds the registry up front via T::register_into and runs the bytes through the wrapper.

§Known gaps vs. the design doc / macro syntax

The wrapper isn’t final — the bits below are accepted by #[derive(MsgpackTagged)] today but the deserializer doesn’t model them yet.

  • deserialize_any. Niche today (none of our ACIR types are decoded via self-describing visitors), but nested tagged values reached through serde_json::Value-style consumers wouldn’t recurse through this wrapper.
  • Encoding strategies. Only the Tagged strategy is decoded. When the serializer gains Array / Named overrides, the deserializer needs the matching shape-agnostic dispatch (peek marker, route to the right reader).

Structs§

ArrayProductMapAccess 🔒
MapAccess adapter for named structs decoded from the Array strategy wire shape (positional fixarray of values). Unlike TaggedProductMapAccess the wire carries no tags; we synthesize the keys yielded to the visitor by walking the merged (active + reserved) wire layout — see merged_wire_layout for why the merge is needed. The visitor still receives (field_name, value) pairs — that’s how serde-derive’s Deserialize for named structs is driven — but the field-name source is the registry, not the wire.
Deserializer
Tagged-map msgpack deserializer.
TaggedAccessViaParent 🔒
Shared access adapter routing each yielded value through the parent Deserializer. The msgpack length-prefixed header (array length for sequences, map length for maps) is consumed up front in the corresponding deserialize_* method before this adapter is built; from there each element/key/value just reads its own bytes through the parent, so any nested tagged values still see this wrapper’s interception.
TaggedEnumAccess 🔒
EnumAccess + VariantAccess adapter for tagged enums.
TaggedProductMapAccess 🔒
MapAccess adapter for tagged structs (and tuple structs once that lands). The wire is an int-keyed msgpack map — each entry’s key is an integer tag that we translate back to the registered field name before handing it to the visitor (which expects a string identifier). Tags not in product.fields are either silently skipped (allow_unknown_tags = true) or rejected (the strict default).
TaggedTupleStructAccess 🔒
SeqAccess adapter for top-level tuple structs (multi-element struct Pair(u32, bool) shapes). Decoded by tag, not by wire order: every wire entry is buffered as (tag, value-bytes) upfront, and on each next_element_seed we look up the tag corresponding to the current source position via Product.tag_for("0"), tag_for("1"), … and re-deserialize the matching entry’s bytes through a freshly constructed sub-wrapper (so any nested tagged types still see this wrapper’s interception).

Enums§

WireShape 🔒
Wire shape of a product value under Format::MsgpackTagged. Picked per struct at decode time by peeking the next msgpack marker — the Serializer choice of EncodingStrategy is not communicated through a separate channel (and doesn’t need to be: the shape is self-describing at the msgpack-header level).

Functions§

merged_wire_layout 🔒
Merge product.fields and product.reserved into a single tag-ascending list of (tag, is_active) pairs.
msgpack_tagged_deserialize
Build the tag registry from T::register_into, then deserialize a value of type T from bytes through a Deserializer.

Type Aliases§

IntKeyedEntries 🔒
Buffered (wire_tag, value-bytes) pairs from an int-keyed map. Inline capacity 4 covers the typical tuple-struct / tuple-variant arity without a heap allocation; anything larger transparently spills.
RmpError 🔒
rmp_serde’s decode-side error type, re-exported for our Deserializer impl. Matches the encode-side RmpError re-export in serializer.rs.