Skip to content

Commit

Permalink
Expose EExpArgGroup and related types, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
zslayton committed Dec 13, 2024
1 parent d55483e commit 014e9dd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exclude = [
"**/ion-tests/iontestdata/**",
"*.pdf"
]
version = "1.0.0-rc.9"
version = "1.0.0-rc.10"
edition = "2021"
rust-version = "1.80"

Expand Down
6 changes: 6 additions & 0 deletions src/lazy/any_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ pub struct AnyEExpArgGroup<'top> {
kind: AnyEExpArgGroupKind<'top>,
}

impl<'a> AnyEExpArgGroup<'a> {
pub fn kind(&self) -> AnyEExpArgGroupKind<'a> {
self.kind
}
}

#[derive(Copy, Clone, Debug)]
pub enum AnyEExpArgGroupKind<'top> {
Text_1_1(TextEExpArgGroup<'top>),
Expand Down
5 changes: 5 additions & 0 deletions src/lazy/binary/raw/v1_1/e_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ impl<'top> BinaryEExpArgGroup<'top> {
self.delimited_values = Some(delimited_values);
self
}

pub fn header_span(&self) -> Span<'_> {
let header_input = self.input.slice(0, self.header_size as usize);
Span::from(header_input)
}
}

impl HasRange for BinaryEExpArgGroup<'_> {
Expand Down
23 changes: 11 additions & 12 deletions src/lazy/binary/raw/v1_1/immutable_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ impl<'a> BinaryBuffer<'a> {
/// Reads the value for a delimited struct field, consuming NOPs if present.
fn peek_delimited_struct_value(
&self,
) -> IonResult<(Option<LazyRawBinaryValue_1_1<'a>>, BinaryBuffer<'a>)> {
) -> IonResult<(Option<LazyRawValueExpr<'a, v1_1::Binary>>, BinaryBuffer<'a>)> {
let opcode = self.expect_opcode()?;
if opcode.is_nop() {
let after_nops = self.consume_nop_padding(opcode)?.1;
Expand All @@ -507,7 +507,7 @@ impl<'a> BinaryBuffer<'a> {
}
Ok((None, after_nops))
} else {
self.read_value(opcode).map(|(v, after)| (Some(v), after))
self.read_sequence_value_expr()
}
}

Expand Down Expand Up @@ -547,7 +547,7 @@ impl<'a> BinaryBuffer<'a> {
return IonResult::incomplete("found field name but no value", after_name.offset());
}

let (value, after_value) = match after_name.peek_delimited_struct_value()? {
let (field, after_value) = match after_name.peek_delimited_struct_value()? {
(None, after) => {
if after.is_empty() {
return IonResult::incomplete(
Expand All @@ -558,16 +558,15 @@ impl<'a> BinaryBuffer<'a> {
buffer = after;
continue; // No value for this field, loop to try next field.
}
(Some(value), after) => (value, after),
(Some(RawValueExpr::ValueLiteral(value)), after) => {
(LazyRawFieldExpr::NameValue(field_name, value), after)
}
(Some(RawValueExpr::EExp(eexp)), after) => {
(LazyRawFieldExpr::NameEExp(field_name, eexp), after)
}
};

let allocator = self.context().allocator();
let value_ref = &*allocator.alloc_with(|| value);

return Ok((
Some(LazyRawFieldExpr::NameValue(field_name, value_ref)),
after_value,
));
return Ok((Some(field), after_value));
}
}

Expand Down Expand Up @@ -619,7 +618,7 @@ impl<'a> BinaryBuffer<'a> {
let input = self;
let header = opcode.to_header().ok_or_else(|| {
IonError::decoding_error(format!(
"found a non-value in value position; buffer=<{:X?}>",
"found a non-value in value position; buffer=<{:02X?}>",
input.bytes_range(0, 16.min(input.bytes().len()))
))
})?;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ macro_rules! v1_x_reader_writer {
lazy::expanded::macro_evaluator::ValueExpr,
lazy::expanded::macro_evaluator::MacroExpr,
lazy::expanded::macro_evaluator::MacroExprKind,
lazy::expanded::macro_evaluator::MacroExprArgsIterator,
};
};
}
Expand Down Expand Up @@ -268,6 +269,7 @@ macro_rules! v1_x_tooling_apis {
LazyRawAnyStruct, LazyRawStructKind,
LazyRawAnyFieldName, LazyRawFieldNameKind,
LazyRawAnyEExpression, LazyRawAnyEExpressionKind,
AnyEExpArgGroup, AnyEExpArgGroupKind, AnyEExpArgGroupIterator
},
lazy::decoder::{
LazyRawSequence,
Expand Down

0 comments on commit 014e9dd

Please sign in to comment.