diff --git a/yaserde/src/ser/mod.rs b/yaserde/src/ser/mod.rs index 2938552..4d96732 100644 --- a/yaserde/src/ser/mod.rs +++ b/yaserde/src/ser/mod.rs @@ -12,6 +12,13 @@ pub fn to_string(model: &T) -> Result { Ok(String::from(data)) } +pub fn to_string_with_config(model: &T, config: &Config) -> Result { + let buf = Cursor::new(Vec::new()); + let cursor = serialize_with_writer(model, buf)?; + let data = str::from_utf8(cursor.get_ref()).expect("Found invalid UTF-8"); + Ok(String::from(data)) +} + pub fn serialize_with_writer(model: &T, writer: W) -> Result { let mut serializer = Serializer::new_from_writer(writer); match model.serialize(&mut serializer) { @@ -93,3 +100,9 @@ impl<'de, W: Write> Serializer { self.writer.write(event) } } + +pub struct Config { + perform_indent: bool, + write_document_declaration: bool, + indent_string: Option +}