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

Removes IonDataSource and vestigial read() impls #591

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

zslayton
Copy link
Contributor

@zslayton zslayton commented Jul 3, 2023

The original implementation of the binary reader used a trait called IonDataSource that provided extension methods for implementations of BufRead. The binary reader was later rewritten to use a type called BinaryBuffer, but IonDataSource and its methods were never removed.

This PR removes IonDataSource and the vestigial implementations of read() for various encoding primitives that relied upon IonDataSource.

Finally, it renames the single-method trait ToIonDataSource (which suggested types could be converted to an IonDataSource) to IonDataSource, reclaiming the name for a better use.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@zslayton zslayton marked this pull request as ready for review July 3, 2023 19:42
Comment on lines -1156 to +1159
// This iterator cannot be created unless the reader is currently parked on a value.
// If the reader is parked on a value, the complete annotations sequence is in the buffer.
// Therefore, reading symbol IDs from this byte slice cannot fail. This allows us to safely
// unwrap the result of this `read` call.
let var_uint = VarUInt::read(&mut self.data).unwrap();
let var_uint = match self.data.read_var_uint() {
Ok(var_uint) => var_uint,
Err(e) => return Some(Err(e)),
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What drives the change here? Is the context about positioning or buffered bytes different now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method VarUInt::read was deleted. The rest of this type uses BinaryBuffer's read operations; this change was changing self.data from being a io::Cursor(&[u8]) that we read from using VarUInt::read() to being a BinaryBuffer<&'a [u8]> that has its own read operation.

The invariant described in the comment is still true; I think I could have kept it but didn't want to do the deep dive needed to guarantee that.

@zslayton zslayton merged commit 1a961e9 into main Jul 3, 2023
19 checks passed
@zslayton zslayton deleted the rm-ion-data-source branch July 3, 2023 20:13
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

Successfully merging this pull request may close these issues.

3 participants