-
Notifications
You must be signed in to change notification settings - Fork 36
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
Modifies the serde serializer to use the new writer #747
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ use crate::lazy::encoder::value_writer::SequenceWriter; | |
use crate::lazy::encoder::write_as_ion::WriteAsIon; | ||
use crate::lazy::encoder::{LazyEncoder, LazyRawWriter, SymbolCreationPolicy}; | ||
use crate::lazy::encoding::{Encoding, TextEncoding_1_0}; | ||
use crate::text::raw_text_writer::{WhitespaceConfig, PRETTY_WHITESPACE_CONFIG}; | ||
use crate::text::raw_text_writer::{ | ||
WhitespaceConfig, COMPACT_WHITESPACE_CONFIG, LINES_WHITESPACE_CONFIG, PRETTY_WHITESPACE_CONFIG, | ||
}; | ||
use crate::types::ParentType; | ||
use crate::{IonResult, TextKind}; | ||
use delegate::delegate; | ||
use std::io::Write; | ||
|
@@ -30,11 +33,6 @@ impl<W: Write> LazyRawTextWriter_1_0<W> { | |
/// Writes the provided data as a top-level value. | ||
pub fn write<V: WriteAsIon>(&mut self, value: V) -> IonResult<&mut Self> { | ||
value.write_as_ion(self.value_writer())?; | ||
write!( | ||
self.output, | ||
"{}", | ||
self.whitespace_config.space_between_top_level_values | ||
)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗺️ This ended up being redundant with whitespace printing handled by the |
||
Ok(self) | ||
} | ||
|
||
|
@@ -50,7 +48,8 @@ impl<W: Write> LazyRawTextWriter_1_0<W> { | |
TextValueWriter_1_0::new( | ||
self, | ||
0, | ||
self.whitespace_config.space_between_top_level_values, | ||
"", // No delimiter between values at the top level | ||
Comment on lines
-53
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm missing something here. I don't see how the other changes allow us to have no delimiter between top level values here. I also don't know why the parent type here is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This code was adding a single space between top level values, but the parameter was actually expecting the caller to provide a delimiter between values --
Each parent type (top level, list, sexp, struct) can construct a |
||
ParentType::TopLevel, | ||
) | ||
} | ||
} | ||
|
@@ -82,7 +81,17 @@ impl<W: Write> LazyRawWriter<W> for LazyRawTextWriter_1_0<W> { | |
/// Build text writer based on given writer configuration | ||
fn build<E: Encoding>(config: WriteConfig<E>, output: W) -> IonResult<Self> { | ||
match &config.kind { | ||
WriteConfigKind::Text(_) => Ok(LazyRawTextWriter_1_0::new(output)), | ||
WriteConfigKind::Text(text_config) => { | ||
let whitespace_config = match text_config.text_kind { | ||
TextKind::Compact => &COMPACT_WHITESPACE_CONFIG, | ||
TextKind::Lines => &LINES_WHITESPACE_CONFIG, | ||
TextKind::Pretty => &PRETTY_WHITESPACE_CONFIG, | ||
}; | ||
Ok(LazyRawTextWriter_1_0 { | ||
output, | ||
whitespace_config, | ||
}) | ||
} | ||
Comment on lines
+84
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗺️ The |
||
WriteConfigKind::Binary(_) => { | ||
unreachable!("Binary writer can not be created from text encoding") | ||
} | ||
|
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
ContainerType
enum defined intypes/mod.rs
was renamed toParentType
because it also includes aTopLevel
variant. AnotherContainerType
was also created that is limited to only containers: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.
It's
IonDatagram
all over again! 😉