pub struct Product {
pub fields: &'static [(Tag, &'static str)],
pub reserved: &'static [Tag],
pub allow_unknown_tags: bool,
pub tag_order_matches_source: bool,
}Expand description
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).
fields is in tag-ascending order (the canonical wire order). reserved
lists tags previously used by this product and now retired — purely
compile-time metadata that prevents reuse, never affects decode behavior.
allow_unknown_tags opts the decoder into silently skipping fields whose
tag isn’t in fields or reserved. Per-field wire-tolerance (i.e. “fill
T::default() when this tag is missing”) is not modeled here — it’s
expressed on the user side via serde-derive’s #[serde(default)], which
is what actually performs the substitution at decode time.
tag_order_matches_source says the user’s source-declaration order is
already tag-ascending — i.e. the order serde-derive will call
serialize_field in matches the canonical wire order. Set by the macro
at derive time. The encoder uses it to skip the buffer-and-sort flush
under the Array strategy when source order is already correct, saving
a per-field Vec<u8> allocation. Under Tagged the encoder always
writes direct (no canonical-byte-order promise), so this flag is
unused there.
Fields§
§fields: &'static [(Tag, &'static str)]§reserved: &'static [Tag]§tag_order_matches_source: boolImplementations§
Source§impl Product
impl Product
Sourcepub fn tag_for(self, field_name: &str) -> Option<Tag>
pub fn tag_for(self, field_name: &str) -> Option<Tag>
Look up a field’s tag by its serde name. O(N) over fields —
acceptable for the small (typically 3-30) field counts of ACIR types;
if a profile ever shows this hot, the registry can precompute
HashMap views.
Sourcepub fn field_for(self, tag: Tag) -> Option<&'static str>
pub fn field_for(self, tag: Tag) -> Option<&'static str>
Look up a field’s serde name by its tag.
Sourcepub fn is_reserved(self, tag: Tag) -> bool
pub fn is_reserved(self, tag: Tag) -> bool
Whether tag is in the product’s reserved list (a retired tag from
an older schema version).