aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Berg <vitiral@gmail.com>2017-07-09 14:38:48 -0600
committerGarrett Berg <vitiral@gmail.com>2017-07-09 14:38:48 -0600
commit3c5a9486cb84c0076ee12b7d40372f819a54ac05 (patch)
treefe5ecc12ec27659ad3e71e29d03b77e9b314fa8a
parentf6673dfdb3f93bacfbf0c0cab4d78bc4154eec0c (diff)
downloadmilf-rs-3c5a9486cb84c0076ee12b7d40372f819a54ac05.tar.gz
milf-rs-3c5a9486cb84c0076ee12b7d40372f819a54ac05.zip
add Settings struct
-rw-r--r--src/ser.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ser.rs b/src/ser.rs
index 77db867..bf12278 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -137,6 +137,21 @@ pub enum Error {
__Nonexhaustive,
}
+/// If given in `Settings` will result in a "pretty array" with the given settings
+/// TODO: add better docs
+#[derive(Debug, Default, Clone)]
+pub struct ArraySettings {
+ indent: u64,
+}
+
+/// Formatting Settings
+/// TODO: add better docs
+#[derive(Debug, Default, Clone)]
+pub struct Settings {
+ array: Option<ArraySettings>,
+ pretty_string: bool,
+}
+
/// Serialization implementation for TOML.
///
/// This structure implements serialization support for TOML to serialize an
@@ -149,6 +164,7 @@ pub enum Error {
pub struct Serializer<'a> {
dst: &'a mut String,
state: State<'a>,
+ settings: Settings,
}
#[derive(Debug, Clone)]
@@ -194,6 +210,7 @@ impl<'a> Serializer<'a> {
Serializer {
dst: dst,
state: State::End,
+ settings: Settings::default(),
}
}
@@ -591,6 +608,7 @@ impl<'a, 'b> ser::SerializeSeq for SerializeSeq<'a, 'b> {
first: &self.first,
type_: &self.type_,
},
+ settings: self.ser.settings.clone(),
})?;
self.first.set(false);
Ok(())
@@ -650,6 +668,7 @@ impl<'a, 'b> ser::SerializeMap for SerializeTable<'a, 'b> {
first: first,
table_emitted: table_emitted,
},
+ settings: ser.settings.clone(),
});
match res {
Ok(()) => first.set(false),
@@ -705,6 +724,7 @@ impl<'a, 'b> ser::SerializeStruct for SerializeTable<'a, 'b> {
first: first,
table_emitted: table_emitted,
},
+ settings: ser.settings.clone(),
});
match res {
Ok(()) => first.set(false),