-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements flexsym annotation reading, adds binary 1.1 roundtrip unit…
… tests (#788) * Adds binary 1.1 roundtrip unit tests, `has_annotations` no longer invokes `annotations` * Implements reading binary FlexSym annotations * Fixes timestamp decoding of offsets * 1.1 binary writer now uses 1 for UTC and 0 for unknown
- Loading branch information
Showing
12 changed files
with
437 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,55 @@ | ||
#![allow(non_camel_case_types)] | ||
use crate::lazy::binary::raw::v1_1::immutable_buffer::ImmutableBuffer; | ||
use crate::{IonResult, RawSymbolRef}; | ||
use crate::lazy::binary::raw::v1_1::immutable_buffer::{AnnotationsEncoding, ImmutableBuffer}; | ||
use crate::lazy::encoder::binary::v1_1::flex_sym::FlexSymValue; | ||
use crate::{IonResult, RawSymbolRef, SymbolId}; | ||
|
||
/// Iterates over a slice of bytes, lazily reading them as a sequence of FlexUInt- or | ||
/// FlexSym-encoded symbol IDs. | ||
pub struct RawBinaryAnnotationsIterator_1_1<'a> { | ||
buffer: ImmutableBuffer<'a>, | ||
encoding: AnnotationsEncoding, | ||
} | ||
|
||
impl<'a> RawBinaryAnnotationsIterator_1_1<'a> { | ||
pub(crate) fn new(buffer: ImmutableBuffer<'a>) -> RawBinaryAnnotationsIterator_1_1<'a> { | ||
Self { buffer } | ||
pub(crate) fn new( | ||
buffer: ImmutableBuffer<'a>, | ||
encoding: AnnotationsEncoding, | ||
) -> RawBinaryAnnotationsIterator_1_1<'a> { | ||
Self { buffer, encoding } | ||
} | ||
} | ||
|
||
impl<'a> Iterator for RawBinaryAnnotationsIterator_1_1<'a> { | ||
type Item = IonResult<RawSymbolRef<'a>>; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
todo!() | ||
if self.buffer.is_empty() { | ||
return None; | ||
} | ||
use AnnotationsEncoding::*; | ||
let (raw_symbol, remaining_input) = match self.encoding { | ||
SymbolAddress => match self.buffer.read_flex_uint() { | ||
Ok((flex_uint, remaining_input)) => ( | ||
RawSymbolRef::SymbolId(flex_uint.value() as SymbolId), | ||
remaining_input, | ||
), | ||
Err(error) => return Some(Err(error)), | ||
}, | ||
FlexSym => { | ||
let (flex_sym, remaining_input) = match self.buffer.read_flex_sym() { | ||
Ok((flex_sym, remaining_input)) => (flex_sym, remaining_input), | ||
Err(error) => return Some(Err(error)), | ||
}; | ||
let raw_symbol = match flex_sym.value() { | ||
FlexSymValue::SymbolRef(raw_symbol) => raw_symbol, | ||
FlexSymValue::Opcode(_) => { | ||
todo!("FlexSym escapes in annotation sequences") | ||
} | ||
}; | ||
(raw_symbol, remaining_input) | ||
} | ||
}; | ||
self.buffer = remaining_input; | ||
Some(Ok(raw_symbol)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.