Module registry

Source
Expand description

Local registry of types participating in tagged-map serialization.

Built once per encode/decode call by walking the type graph from a top-level type via MsgpackTagged::register_into. The wrapper Serializer/Deserializer consults this registry to translate between serde field names and integer tags.

§Wire-shape model

A tagged type is one of two algebraic shapes:

  • A Product — a fixed list of (tag, name) field entries. Used for structs, tuple structs, and (recursively) for an enum variant’s payload.
  • A Sum — a discriminated union of Variants, each carrying its own Product payload.

Both shapes are unified under Tagged, which is the only thing the trait exposes (via the TAGGED associated const). The registry stores Tagged values keyed by serde name and routes wrapper code through the matching arm.

Every type used here (Tagged, Product, Variant, Sum) is Copy with public fields — they’re built directly in const context by the derive macro and read flatly from the trait, so there’s no encapsulated state to protect.

Structs§

Entry
A registered type’s metadata. Stores only the type’s Tagged shape alongside a TypeId used to detect serde-name collisions between different Rust types.
Product
A product type — a fixed list of named, integer-tagged fields. Used for top-level structs/tuple structs and for an enum variant’s payload (a variant is structurally just a struct hung off a tag).
Sum
A sum type — a discriminated union of Variants.
TagRegistry
A registry of types participating in tagged-map serialization.
Variant
One variant of a sum type. Its payload is a single Product (possibly with no fields for unit and newtype variants — see VariantKind for the discriminator that distinguishes them).

Enums§

Tagged
The wire shape of a tagged type, used both at the top level (in MsgpackTagged::TAGGED) and recursively inside variant payloads.
VariantKind
The shape of an enum variant’s payload, used by the wrapper to decide how to encode/decode the value carried under the variant tag.

Functions§

type_name_basename
The basename component of std::any::type_name::<T>() — module path stripped, generic parameters dropped. Used by the strategy-override machinery to look up registered types by the same serde name that #[serde(rename = "...")] (or the bare type ident) maps to.