Skip to content

Commit 8366d0e

Browse files
authored
Expose EExpArgGroup and related types, version bump (#881)
1 parent d55483e commit 8366d0e

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exclude = [
1616
"**/ion-tests/iontestdata/**",
1717
"*.pdf"
1818
]
19-
version = "1.0.0-rc.9"
19+
version = "1.0.0-rc.10"
2020
edition = "2021"
2121
rust-version = "1.80"
2222

src/lazy/any_encoding.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ pub struct AnyEExpArgGroup<'top> {
280280
kind: AnyEExpArgGroupKind<'top>,
281281
}
282282

283+
impl<'a> AnyEExpArgGroup<'a> {
284+
pub fn kind(&self) -> AnyEExpArgGroupKind<'a> {
285+
self.kind
286+
}
287+
}
288+
283289
#[derive(Copy, Clone, Debug)]
284290
pub enum AnyEExpArgGroupKind<'top> {
285291
Text_1_1(TextEExpArgGroup<'top>),

src/lazy/binary/raw/v1_1/e_expression.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,11 @@ impl<'top> BinaryEExpArgGroup<'top> {
451451
self.delimited_values = Some(delimited_values);
452452
self
453453
}
454+
455+
pub fn header_span(&self) -> Span<'_> {
456+
let header_input = self.input.slice(0, self.header_size as usize);
457+
Span::from(header_input)
458+
}
454459
}
455460

456461
impl HasRange for BinaryEExpArgGroup<'_> {

src/lazy/binary/raw/v1_1/immutable_buffer.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl<'a> BinaryBuffer<'a> {
497497
/// Reads the value for a delimited struct field, consuming NOPs if present.
498498
fn peek_delimited_struct_value(
499499
&self,
500-
) -> IonResult<(Option<LazyRawBinaryValue_1_1<'a>>, BinaryBuffer<'a>)> {
500+
) -> IonResult<(Option<LazyRawValueExpr<'a, v1_1::Binary>>, BinaryBuffer<'a>)> {
501501
let opcode = self.expect_opcode()?;
502502
if opcode.is_nop() {
503503
let after_nops = self.consume_nop_padding(opcode)?.1;
@@ -507,7 +507,7 @@ impl<'a> BinaryBuffer<'a> {
507507
}
508508
Ok((None, after_nops))
509509
} else {
510-
self.read_value(opcode).map(|(v, after)| (Some(v), after))
510+
self.read_sequence_value_expr()
511511
}
512512
}
513513

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

550-
let (value, after_value) = match after_name.peek_delimited_struct_value()? {
550+
let (field, after_value) = match after_name.peek_delimited_struct_value()? {
551551
(None, after) => {
552552
if after.is_empty() {
553553
return IonResult::incomplete(
@@ -558,16 +558,15 @@ impl<'a> BinaryBuffer<'a> {
558558
buffer = after;
559559
continue; // No value for this field, loop to try next field.
560560
}
561-
(Some(value), after) => (value, after),
561+
(Some(RawValueExpr::ValueLiteral(value)), after) => {
562+
(LazyRawFieldExpr::NameValue(field_name, value), after)
563+
}
564+
(Some(RawValueExpr::EExp(eexp)), after) => {
565+
(LazyRawFieldExpr::NameEExp(field_name, eexp), after)
566+
}
562567
};
563568

564-
let allocator = self.context().allocator();
565-
let value_ref = &*allocator.alloc_with(|| value);
566-
567-
return Ok((
568-
Some(LazyRawFieldExpr::NameValue(field_name, value_ref)),
569-
after_value,
570-
));
569+
return Ok((Some(field), after_value));
571570
}
572571
}
573572

@@ -619,7 +618,7 @@ impl<'a> BinaryBuffer<'a> {
619618
let input = self;
620619
let header = opcode.to_header().ok_or_else(|| {
621620
IonError::decoding_error(format!(
622-
"found a non-value in value position; buffer=<{:X?}>",
621+
"found a non-value in value position; buffer=<{:02X?}>",
623622
input.bytes_range(0, 16.min(input.bytes().len()))
624623
))
625624
})?;

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ macro_rules! v1_x_reader_writer {
230230
lazy::expanded::macro_evaluator::ValueExpr,
231231
lazy::expanded::macro_evaluator::MacroExpr,
232232
lazy::expanded::macro_evaluator::MacroExprKind,
233+
lazy::expanded::macro_evaluator::MacroExprArgsIterator,
233234
};
234235
};
235236
}
@@ -268,6 +269,7 @@ macro_rules! v1_x_tooling_apis {
268269
LazyRawAnyStruct, LazyRawStructKind,
269270
LazyRawAnyFieldName, LazyRawFieldNameKind,
270271
LazyRawAnyEExpression, LazyRawAnyEExpressionKind,
272+
AnyEExpArgGroup, AnyEExpArgGroupKind, AnyEExpArgGroupIterator
271273
},
272274
lazy::decoder::{
273275
LazyRawSequence,

0 commit comments

Comments
 (0)