-
Notifications
You must be signed in to change notification settings - Fork 35
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
Adds a 1.1 ValueWriter
setting for writing symbol text inline
#804
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ PR tour
let header = type_descriptor.to_header().ok_or_else(|| { | ||
IonError::decoding_error(format!( | ||
"found a non-value in value position; buffer=<{:X?}>", | ||
input.bytes_range(0, 16.min(input.bytes().len())) | ||
)) | ||
})?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ The old error message was maddening. Now you can at least see the unexpected opcode.
if input.len() < flex_sym_end { | ||
return IonResult::incomplete("reading a FlexSym", offset); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ If the buffer ended in the middle of a FlexSym
, it would lead to a panic instead of reporting Incomplete
.
src/lazy/encoder/writer.rs
Outdated
if self.encoding.symbol_creation_policy == SymbolCreationPolicy::WriteProvidedToken { | ||
if self.has_inline_symbol_text() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ has_inline_symbol_text
is more specific than the initial SymbolCreationPolicy
. It may be that I can remove that concept, but if so I'll do that in another PR.
src/lazy/encoder/writer.rs
Outdated
// Store the tokens as they are. Text will be written as text, symbol IDs will be written | ||
// as symbol IDs. TODO: Lookup SIDs to see if they have text? | ||
// as symbol IDs. | ||
// TODO: Replace SIDs w/text if they're defined? (Config setting?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ If the caller passes a SID, we write it as-is. At a minimum, we should validate that it's in range.
let item = reader.next_item()?; | ||
match item { | ||
SystemStreamItem::VersionMarker(marker) => { | ||
// Note that this uses the Ion version with which the IVM was encoded rather than | ||
// the Ion version the stream is switching to. We can do this because the format | ||
// (i.e text or binary) stays the same when the version changes. | ||
// TODO: Use new encoding, once we have APIs to get new/old encodings for the marker. | ||
let is_human_readable = marker.encoding().is_text(); | ||
let value = reader.expect_next_value()?; | ||
let value_deserializer = ValueDeserializer::new(&value, is_human_readable); | ||
T::deserialize(value_deserializer) | ||
} | ||
SystemStreamItem::Value(value) => { | ||
let value_deserializer = ValueDeserializer::new(&value, true); | ||
T::deserialize(value_deserializer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ This old implementation would return an error if an LST preceded the first value.
This PR builds on the changes in #802.
To start, the setting currently governs symbol values and annotations. There is not yet a way to:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.