Struct Product

Source
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]§allow_unknown_tags: bool§tag_order_matches_source: bool

Implementations§

Source§

impl Product

Source

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.

Source

pub fn field_for(self, tag: Tag) -> Option<&'static str>

Look up a field’s serde name by its tag.

Source

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).

Source

pub const fn empty() -> Self

Empty Product used for primitives and newtypes.

Trait Implementations§

Source§

impl Clone for Product

Source§

fn clone(&self) -> Product

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Product

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for Product

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.