On Thu Aug 27, 2026 at 11:12 PM JST, Eliot Courtney wrote:
<...>
> +    /// Decodes every pair into `schema` and returns the result of 
> [`Schema::finish`].
> +    pub(crate) fn decode<'s, S: Schema>(
> +        &self,
> +        schema: &'s mut S,
> +    ) -> Result<impl Init<S::Target, Error> + 's> {
> +        let mut cursor = Cursor::new(self.data);
> +        while !cursor.is_empty() {
> +            let op: Op = cursor.take_u64()?.into();
> +
> +            let key = op.key().into();
> +            let index = op.index();
> +            let op_value: u32 = op.value().into();
> +            match op.opcode()? {
> +                Opcode::Imm32 => {
> +                    self.visit(schema, key, index, 
> DecoderValue::Scalar32(op_value))?;
> +                }
> +                Opcode::Seq32 => {
> +                    let values = 
> cursor.take_u32s(num::u32_as_usize(op_value))?;
> +                    for (i, &value) in values.iter().enumerate() {
> +                        let key = Self::seq_key(key, i)?;
> +                        self.visit(schema, key, index, 
> DecoderValue::Scalar32(value))?;
> +                    }
> +                }
> +                Opcode::Seq64 => {
> +                    let values = 
> cursor.take_u64s(num::u32_as_usize(op_value))?;
> +                    for (i, &value) in values.iter().enumerate() {
> +                        let key = Self::seq_key(key, i)?;
> +                        self.visit(schema, key, index, 
> DecoderValue::Scalar64(value))?;
> +                    }
> +                }

Another thing that could be worth clarifying: are `Seq32`/`Seq64` with a
count of `0` valid? Right now they won't trigger a visit or an error,
i.e. they will be silently ignored. Whereas arrays of size 0 do trigger
a visit (which sounds logical). I'm not saying this is a problem, just
wondering if the behavior is consistent with what NVKV specifies in such
cases.

Reply via email to