struct TaggedTupleStructAccess<'der, 'a, 'de> {
parent: &'der mut Deserializer<'a, 'de>,
product: Product,
entries: SmallVec<[(u8, &'de [u8]); 4]>,
next_position: usize,
}Expand description
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).
This is what makes the deserializer robust to wire-order changes on the serializer side: if the serializer is fixed to emit tag-ascending (matching the design doc) — or some other order — we don’t need to touch this code, because we route by tag.
Buffering. value-bytes is captured by snapshotting the inner
reader’s &[u8] before and after each IgnoredAny::deserialize walk
(which advances exactly one msgpack value worth of bytes). Slicing
the diff out of the original buffer gives us the exact byte range
for that one value. The captured slice is &'de [u8] — same
underlying buffer, no copy.
Inline capacity. SmallVec<[_; 4]> covers the typical tuple-
struct arity (current ACIR/Brillig types use exclusively newtypes;
our test fixtures top out at 3-element tuple structs) without a
heap allocation. Anything larger transparently spills.
Fields§
§parent: &'der mut Deserializer<'a, 'de>§product: Product§entries: SmallVec<[(u8, &'de [u8]); 4]>Buffered (tag, value-bytes) pairs in wire arrival order. We look
these up by tag in next_element_seed; insertion order doesn’t
matter.
next_position: usizeTrait Implementations§
Source§impl<'de, 'der, 'a> SeqAccess<'de> for TaggedTupleStructAccess<'der, 'a, 'de>
impl<'de, 'der, 'a> SeqAccess<'de> for TaggedTupleStructAccess<'der, 'a, 'de>
Source§type Error = Error
type Error = Error
Source§fn next_element_seed<T>(
&mut self,
seed: T,
) -> Result<Option<T::Value>, Self::Error>where
T: DeserializeSeed<'de>,
fn next_element_seed<T>(
&mut self,
seed: T,
) -> Result<Option<T::Value>, Self::Error>where
T: DeserializeSeed<'de>,
Ok(Some(value)) for the next value in the sequence, or
Ok(None) if there are no more remaining items. Read moreSource§fn size_hint(&self) -> Option<usize>
fn size_hint(&self) -> Option<usize>
Source§fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>where
T: Deserialize<'de>,
fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>where
T: Deserialize<'de>,
Ok(Some(value)) for the next value in the sequence, or
Ok(None) if there are no more remaining items. Read more