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

Ion Element/Value API #114

Closed
rhinomode opened this issue Jan 7, 2021 · 2 comments
Closed

Ion Element/Value API #114

rhinomode opened this issue Jan 7, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@rhinomode
Copy link

Hello, this is a request for enhancing/extending the functionality provided to Rust Ion users.

The IonJava and IonElement libraries provide useful abstractions over Ion readers and writers (which themselves are very useful).

As a user of the ion-rs crates, I find myself wanting a API similar to those found in the Java libraries (above) or the serde-rs/json crate.

The reason is simple: to make sensible code, I must build structures (enum even) around the ion-rs/* functions and constants. Then I must also consider all of the other low-level concerns of (lazily) materializing, (avoiding) clones of effectively immutable data to satisfy the borrow checker, etc. etc.

I suspect can and should be "solved once" as in the Java prior art.

Thanks,
Chuck

@rhinomode
Copy link
Author

There's some interesting test code from Almann along these lines in the ion-c-sys crate - obviously not meant for consumption outside the test harness.

almann added a commit that referenced this issue Mar 23, 2021
Provides an _borrowed_/_owned_ implementations of the traits in the
`value` module.  The borrowed implementation is tied to a lifetime for
string/binary data (but potentially more in the future).  The owned
implementation is completely self contained.

* Defines `SymbolToken` and `ImportSource` traits that is the basis for
  full symbol/field name/annotation support in `ion-rs`, but also is
  required for the `Element` trait.
* APIs that return `Iterator` types currently use a `Box` to avoid the
  need for generic associated types (GAT).
* Captures the variance of integers in Ion with the `IntAccess` trait
  and the `AnyInt` enum.
* Currently implements the `Struct` trait via `Vec` of tuples, which
  will have to be refactored for O(N) access but is suitable for the
  iterator APIS.

Starts to address #114, but is not nearly complete.  This commit is to
provide the initial structure of this API for collaborative development,
and to get early review.
almann added a commit that referenced this issue Mar 26, 2021
Provides an _borrowed_/_owned_ implementations of the traits in the
`value` module.  The borrowed implementation is tied to a lifetime for
string/binary data (but potentially more in the future).  The owned
implementation is completely self contained.

* Defines `SymbolToken` and `ImportSource` traits that is the basis for
  full symbol/field name/annotation support in `ion-rs`, but also is
  required for the `Element` trait.
* APIs that return `Iterator` types currently use a `Box` to avoid the
  need for generic associated types (GAT).
* Captures the variance of integers in Ion with the `IntAccess` trait
  and the `AnyInt` enum.
* Currently implements the `Struct` trait via `Vec` of tuples, which
  will have to be refactored for O(N) access but is suitable for the
  iterator APIS.

Starts to address #114, but is not nearly complete.  This commit is to
provide the initial structure of this API for collaborative development,
and to get early review.
@almann almann added the enhancement New feature or request label Mar 27, 2021
@almann almann pinned this issue Mar 30, 2021
almann pushed a commit that referenced this issue Mar 30, 2021
* Adds `Sequence` methods: `get`, `len`, `is_empty`.
* Adds `Struct` methods: `get`, `get_all`.
* `Struct` uses a `HashMap` with `(key, values) -> (String, Vec<(SymbolToken, Element)>)`
  as well as a `Vec<(Symboltoken, Element)>` to store fields with no text `SymbolToken`

Rebases #132 and related to #114.
@zslayton
Copy link
Contributor

The Element API has been heavily revised (see: #479, #485, #486, #487); these changes will be included in the next release.

@almann almann unpinned this issue Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants