Function msgpack_tagged_serialize_acir

Source
pub(crate) fn msgpack_tagged_serialize_acir<T>(value: &T) -> Result<Vec<u8>>
Expand description

Serialize a value through the msgpack_tagged wrapper with the ACIR policy applied: by default everything reachable from value rides on EncodingStrategy::Array (the compact positional shape), and the top-level container types (Program, Circuit, BrilligBytecode) flip to EncodingStrategy::Tagged so they stay schema-evolvable. The overrides use with_strategy_for_name, which never asserts on a registry miss — so the same call works when value doesn’t reach any of those containers (e.g. a WitnessMap or a bare leaf type): unreachable names get a stray override entry that’s never looked up at encode time.

Targeting types by serde name rather than Rust type matches the wire identity directly: it doesn’t matter which field flavor (FieldElement, GenericFieldElement<X>, …) the caller is using — every Program<_> registers as "Program". The shadow-DTO pattern (Circuit<F> delegates to CircuitWire<F> which registers under "Circuit" via #[serde(rename = "Circuit")]) is likewise transparent here.