From 3c5a9486cb84c0076ee12b7d40372f819a54ac05 Mon Sep 17 00:00:00 2001 From: Garrett Berg Date: Sun, 9 Jul 2017 14:38:48 -0600 Subject: add Settings struct --- src/ser.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/ser.rs') 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, + 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), -- cgit v1.2.3