-
Notifications
You must be signed in to change notification settings - Fork 159
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
Defer bitfield decoding until its first use #803
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but can you update the branch so I can make sure there is no regression? Hard to verify specifics with a few of the cases
utils/bitfield/src/unvalidated.rs
Outdated
impl Serialize for UnvalidatedBitField { | ||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
match self { | ||
Self::Validated(bf) => serde_bytes::serialize(&bf.to_bytes(), serializer), | ||
Self::Unvalidated(bytes) => serde_bytes::serialize(&bytes, serializer), | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optionally, can remove impl for this with serde untagged
https://serde.rs/enum-representations.html#untagged (prob best to keep the deserialize either way)
This PR adds the
UnvalidatedBitField
type that may or may not have been validated for valid RLE+ yet. The existingBitField
type still represents validated bitfields only.Also adds the
bitfield::Validate
trait which is useful for when a function needs to be able to work with both validated and unvalidated bitfields.Closes #735