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

Module cleanup, adds Element::expect_*, removes IntAccess #595

Merged
merged 5 commits into from
Jul 7, 2023

Conversation

zslayton
Copy link
Contributor

@zslayton zslayton commented Jul 6, 2023

This PR:

  • Hides several modules that were previously public.
  • Makes the contents of the types and element modules visible at the root level.
  • Normalizes all imports to use the root path where possible.
  • Renames Precision to TimestampPrecision since it is now visible at the root level.
  • Removes the IntAccess trait, which was introduced when we had the borrowed implementation of Element. The as_i64() method is now natively available on both Element and Int.
  • Adds some additional TryFrom/From implementations for Int.

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

@codecov
Copy link

codecov bot commented Jul 6, 2023

Codecov Report

Patch coverage: 44.09% and project coverage change: -0.39 ⚠️

Comparison is base (5510b3f) 82.84% compared to head (9763fc8) 82.45%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #595      +/-   ##
==========================================
- Coverage   82.84%   82.45%   -0.39%     
==========================================
  Files         111      111              
  Lines       19302    19399      +97     
  Branches    19302    19399      +97     
==========================================
+ Hits        15990    15996       +6     
- Misses       1770     1856      +86     
- Partials     1542     1547       +5     
Impacted Files Coverage Δ
src/binary/binary_writer.rs 64.67% <ø> (ø)
src/binary/decimal.rs 89.15% <ø> (ø)
src/binary/header.rs 0.00% <ø> (ø)
src/binary/int.rs 75.67% <ø> (ø)
src/binary/non_blocking/binary_buffer.rs 94.08% <ø> (ø)
src/binary/non_blocking/type_descriptor.rs 30.00% <ø> (ø)
src/binary/raw_binary_writer.rs 85.17% <ø> (ø)
src/binary/type_code.rs 28.12% <ø> (ø)
src/binary/uint.rs 89.74% <ø> (ø)
src/blocking_reader.rs 76.08% <ø> (ø)
... and 50 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@zslayton zslayton marked this pull request as ready for review July 6, 2023 21:08
@zslayton zslayton requested a review from popematt July 6, 2023 21:08
@zslayton zslayton requested a review from desaikd July 6, 2023 21:10
use ion_rs::RawStreamItem;
use ion_rs::{BlockingRawBinaryReader, IonReader, IonType, RawReader, StreamItem, UserReader};
use ion_rs::{
BlockingRawBinaryReader, IonReader, IonResult, IonType, RawBinaryReader, RawReader,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intentional that we're exporting "raw" readers at the root?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't really thought through how I'd like to expose all of the types that are behind experimental feature flags yet. Open to suggestions.

Comment on lines +184 to +186
pub mod element;
pub mod result;
pub mod types;
Copy link
Contributor

Choose a reason for hiding this comment

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

So, just to make sure I'm understanding correctly, we're exporting everything here and at the root?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we're exporting everything here

There are some types that I don't think are commonly used enough (at least by name) to merit a spot in the crate root (OwnedElementIterator, FractionalSecondSetter, etc).

That said, there aren't that many of them and they're pretty distinctively named, so I could also be convinced not to expose any modules at all.

@@ -224,6 +214,8 @@ pub use {
blocking_reader::{BlockingRawBinaryReader, BlockingRawReader, BlockingRawTextReader},
ion_reader::IonReader,
raw_reader::{BufferedRawReader, RawReader, RawStreamItem},
raw_symbol_token::RawSymbolToken,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious. Do you think it would be helpful, neutral, or unhelpful for everything in the experimental-reader feature to be exported under ion_rs::reader as a way of making the namespaces somewhat match the features?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends -- if we're leaning towards a pretty flat namespace, I don't think it would help that much. If we think we'll ultimately have visible modules, it might be somewhat helpful.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if we're leaning towards a flat namespace. I do think that the most common things should probably be at the front and center.

That being said, I think figuring this out would be a blocking issue for stabilizing the reader feature, but not for the v1.0 release.

@@ -15,7 +15,7 @@ use std::ops::Div;

/// Indicates the most precise time unit that has been specified in the accompanying [Timestamp].
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Default)]
pub enum Precision {
pub enum TimestampPrecision {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

@zslayton zslayton merged commit 9501cd2 into main Jul 7, 2023
20 of 21 checks passed
@zslayton zslayton deleted the module-cleanup branch July 7, 2023 04:53
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.

None yet

2 participants