Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement proper fix for "Broken deserialization of Lists with offsets" (#248) #250

Open
chmp opened this issue Oct 23, 2024 · 0 comments
Open

Comments

@chmp
Copy link
Owner

chmp commented Oct 23, 2024

The current fix for #248 requires skips the elements by deserializing any skipped values. Figure out an alternative that avoids any unnecessary work. Ideas:

  • Add skip to the interface of the deserializers and implement a solution by shifting around the offsets
  • Implement random access deserialization
    • This will also allow to deserialize enums with holes or lists with null values with data
    • This would also allow to support lists with non-monotically increasing offsets (although such lists could be ill formed)

Potential design of RandomAccessDeserializer

trait RandomAccessDeserializer {
  /// Get the number of items
  fn len(&self) -> usize;
  /// Deserialize the `i`-th item of this deserializer into the given type
  fn get<'de, T: Deserialize<'de>>(&'de self, i: usize) -> Result<T>;
}

struct Deserializer {
  inner: StructDeserializer,
  next: usize,
  len: usize,
}

// impl Deserializer analogous to OuterSequenceDeserializer
@chmp chmp changed the title Implement proper fix for #248 Implement proper fix for "Broken deserialization of Lists with offsets" (#248) Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant