diff --git a/Cargo.toml b/Cargo.toml index 041ba407..2654e423 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/lazy/any_encoding.rs b/src/lazy/any_encoding.rs index 4423d64c..8274373f 100644 --- a/src/lazy/any_encoding.rs +++ b/src/lazy/any_encoding.rs @@ -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>), diff --git a/src/lazy/binary/raw/v1_1/e_expression.rs b/src/lazy/binary/raw/v1_1/e_expression.rs index dc755022..cee88bea 100644 --- a/src/lazy/binary/raw/v1_1/e_expression.rs +++ b/src/lazy/binary/raw/v1_1/e_expression.rs @@ -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<'_> { diff --git a/src/lazy/binary/raw/v1_1/immutable_buffer.rs b/src/lazy/binary/raw/v1_1/immutable_buffer.rs index 5bdc1291..7080f02a 100644 --- a/src/lazy/binary/raw/v1_1/immutable_buffer.rs +++ b/src/lazy/binary/raw/v1_1/immutable_buffer.rs @@ -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>, BinaryBuffer<'a>)> { + ) -> IonResult<(Option>, BinaryBuffer<'a>)> { let opcode = self.expect_opcode()?; if opcode.is_nop() { let after_nops = self.consume_nop_padding(opcode)?.1; @@ -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() } } @@ -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( @@ -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)); } } @@ -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())) )) })?; diff --git a/src/lib.rs b/src/lib.rs index b88629ed..3ebdcf9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, }; }; } @@ -268,6 +269,7 @@ macro_rules! v1_x_tooling_apis { LazyRawAnyStruct, LazyRawStructKind, LazyRawAnyFieldName, LazyRawFieldNameKind, LazyRawAnyEExpression, LazyRawAnyEExpressionKind, + AnyEExpArgGroup, AnyEExpArgGroupKind, AnyEExpArgGroupIterator }, lazy::decoder::{ LazyRawSequence,