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

Move the Ion value types to the types module #543

Merged
merged 3 commits into from
May 1, 2023

Conversation

popematt
Copy link
Contributor

@popematt popematt commented May 1, 2023

Issue #, if available:

None.

Description of changes:

This moves the "types" to the types module, as per:

//! This module provides an implementation of the data types described by the
//! [Ion Data Model](https://amazon-ion.github.io/ion-docs/docs/spec.html#the-ion-data-model)
//! section of the Ion 1.0 spec.

It also makes it so that all of the types in the types module are exposed as part of types rather than as part of a submodule of types.

Note that this is just fixing the internal organization of this code. How these types are exposed publicly is another matter that should also be fixed. In some cases, we are exporting the same type at multiple locations. (e.g. ion_rs::Symbol, ion_rs::types::Symbol, ion_rs::element::Symbol) and that's just asking for confusion.

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 May 1, 2023

Codecov Report

Patch coverage: 86.95% and no project coverage change.

Comparison is base (33a8fb9) 83.07% compared to head (4a440af) 83.07%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #543   +/-   ##
=======================================
  Coverage   83.07%   83.07%           
=======================================
  Files          83       83           
  Lines       16126    16126           
  Branches    16126    16126           
=======================================
  Hits        13396    13396           
  Misses       1566     1566           
  Partials     1164     1164           
Impacted Files Coverage Δ
src/binary/binary_writer.rs 62.87% <ø> (ø)
src/binary/decimal.rs 89.24% <ø> (ø)
src/binary/int.rs 82.80% <ø> (ø)
src/binary/non_blocking/binary_buffer.rs 94.17% <ø> (ø)
src/binary/non_blocking/raw_binary_reader.rs 79.64% <ø> (ø)
src/binary/raw_binary_writer.rs 85.58% <ø> (ø)
src/binary/timestamp.rs 76.82% <ø> (ø)
src/binary/uint.rs 92.30% <ø> (ø)
src/blocking_reader.rs 73.81% <ø> (ø)
src/element/builders.rs 90.19% <ø> (ø)
... and 32 more

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

Copy link
Contributor

@almann almann left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me. Minor cleanup asks below.

I do wonder if types::iterators having stuff that is germane to Element/ElementsIterator and Annotations iterators are in the right place. Generally iterator implementations should live near what they iterate over. So we either break out those things that are relevant to the type module or refactor it as a separate PR. Thoughts?

src/binary/non_blocking/binary_buffer.rs Outdated Show resolved Hide resolved
Comment on lines +12 to +17
use crate::types::IntAccess;
use crate::types::Str;
use crate::types::SymbolId;
use crate::types::{Blob, Clob};
use crate::{
raw_reader::BufferedRawReader, Decimal, Int, IonReader, IonResult, IonType, RawStreamItem,
RawSymbolToken, Timestamp,
raw_reader::BufferedRawReader, types::Decimal, Int, IonReader, IonResult, IonType,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consolidate these crate::types::{...} imports, especially the one that says types::Decimal.

Comment on lines +14 to 16
use crate::types::Decimal;
use crate::types::Timestamp;
use crate::types::{ContainerType, SymbolId};
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consolidate these.

Comment on lines +915 to +916
use crate::types::Symbol;
use crate::types::{Blob, Clob};
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consolidate these.

Comment on lines 32 to +40
// Re-export the Value variant types and traits so they can be accessed directly from this module.
pub use self::bytes::Bytes;
pub use crate::types::Bytes;
pub use crate::types::{Blob, Clob};
pub use annotations::{Annotations, IntoAnnotations};
pub use lob::{Blob, Clob};

pub use list::List;
pub use r#struct::Struct;
pub use sequence::Sequence;
pub use sexp::SExp;
pub use crate::types::List;
pub use crate::types::SExp;
pub use crate::types::Sequence;
pub use crate::types::Struct;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would at least put these together so they rustfmt together.

Comment on lines +16 to +18
use crate::types::Decimal;
use crate::types::UInt;
use crate::types::{Coefficient, Sign};
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably should make these all types::{...} or each on their own line.

Comment on lines +17 to +18
use crate::types::Decimal;
use crate::types::{FractionalSecondSetter, Timestamp};
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider consolidating these imports/making them consistent.

Comment on lines +9 to +10
use crate::types::UInt;
use crate::types::{Coefficient, Sign};
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider consolidating these imports/making them consistent.

Comment on lines +390 to +391
use crate::types::Decimal;
use crate::types::{Coefficient, Sign};
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider consolidating these imports/making them consistent.

Comment on lines 102 to 104
pub(crate) current: usize,
pub(crate) indexes: Option<&'a IndexVec>,
pub(crate) by_index: &'a Vec<(Symbol, Element)>,
Copy link
Contributor

Choose a reason for hiding this comment

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

See my top-level comment, this seems to indicate it is not in the right place.

@popematt
Copy link
Contributor Author

popematt commented May 1, 2023

@almann I have moved the Element and Symbol iterators back to the elements mod. If you don't mind, I'd prefer to handle all of the style/formatting clean up in a followup PR.

Copy link
Contributor

@almann almann left a comment

Choose a reason for hiding this comment

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

:shipit: LGTM

@popematt popematt merged commit b8e8e82 into amazon-ion:main May 1, 2023
18 checks passed
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