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

Support for encoding directives, arg groups, length-prefixed e-expressions #796

Merged
merged 14 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ edition = "2021"
# We need at least 1.65 for GATs[1] and 1.67 for `ilog`[2]
# [1] https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html
# [2] https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html#stabilized-apis
rust-version = "1.67"
rust-version = "1.77"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ Bumping this again while we still can--1.77 added some nice const generics functionality for breaking apart byte arrays.

Copy link
Contributor

Choose a reason for hiding this comment

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

while we still can

There's a cfg_version RFC that will help with this.

Also, if we haven't already done so, we should define a MSRV policy for this crate.


[features]
default = []
Expand Down Expand Up @@ -63,6 +63,7 @@ smallvec = { version = "1.9.0", features = ["const_generics"] }
bumpalo = { version = "3.15.3", features = ["collections", "std"] }
digest = { version = "0.9", optional = true }
ice_code = "0.1.4"
rustc-hash = "2.0.0"
sha2 = { version = "0.9", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_with = { version = "3.7.0", optional = true }
Expand Down
495 changes: 435 additions & 60 deletions benches/read_many_structs.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions benches/write_many_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod benchmark {
&[
black_box("SUCCESS"),
black_box("example-client-1"),
black_box("aws-us-east-5f-18b4fa"),
black_box("aws-us-east-5f-abc-123"),
black_box("region 4"),
black_box("2022-12-07T20:59:59.744000Z"),
],
Expand Down Expand Up @@ -73,7 +73,7 @@ mod benchmark {
symbol_id(black_box(21)),
// $22 = example-client-1
symbol_id(black_box(22)),
// $23 = aws-us-east-5f-18b4fa
// $23 = aws-us-east-5f-abc-123
symbol_id(black_box(23)),
// $24 = region 4
symbol_id(black_box(24)),
Expand All @@ -92,7 +92,7 @@ mod benchmark {
// them wouldn't be beneficial.
.write(black_box("6"))? // thread_name
.write(black_box("1"))? // client_num
.write(symbol_id(black_box(10)))?; // host_id: "18b4fa" ($10)
.write(symbol_id(black_box(10)))?; // host_id: "abc-123" ($10)
let mut nested_eexp = eexp.eexp_writer(1)?;
nested_eexp
// $11 = region 4
Expand All @@ -109,7 +109,7 @@ mod benchmark {
.write(black_box(418))? // thread_id
.write(black_box("6"))? // thread_name
.write(black_box("1"))? // client_num
.write(black_box("18b4fa"))?; // host_id
.write(black_box("abc-123"))?; // host_id
let mut nested_eexp = eexp.eexp_writer(1)?;
nested_eexp
.write(black_box("region 4"))?
Expand Down
19 changes: 18 additions & 1 deletion src/element/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,34 @@ use crate::lazy::encoding::Encoding;
use crate::write_config::WriteConfig;
use crate::IonResult;
use std::cmp::Ordering;
use std::fmt::{Debug, Formatter};
use std::io;

/// An iterable, addressable series of Ion [`Element`]s.
///
/// A `Sequence` is not itself an Ion value type, but can represent a series of Ion values appearing
/// in a [`List`](crate::List), a [`SExp`](crate::SExp), or at the top level.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
pub struct Sequence {
elements: Vec<Element>,
}

impl Debug for Sequence {
zslayton marked this conversation as resolved.
Show resolved Hide resolved
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "Sequence<")?;
let mut is_first = true;
for element in self {
if is_first {
write!(f, "{element}")?;
} else {
write!(f, ", {element}")?;
is_first = false;
}
}
write!(f, ">")
}
}

impl Sequence {
pub fn new<E: Into<Element>, I: IntoIterator<Item = E>>(elements: I) -> Sequence {
let elements = elements.into_iter().map(|e| e.into()).collect();
Expand Down
Loading
Loading