From 34cf5076f9b9108a8f31c5f15ad69e921e85b00a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 2 Dec 2015 11:52:36 +0100 Subject: [PATCH] Reimplement JsonHeaderParser::write() --- src/storage/json/parser.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index fc663303..b2ea1e1d 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -45,9 +45,16 @@ impl FileHeaderParser for JsonHeaderParser { } fn write(&self, data: &FileHeaderData) -> Result { - let mut ser = Serializer::pretty(stdout()); - data.serialize(&mut ser); - Ok(String::from("")) + let mut s = Vec::::new(); + { + let mut ser = Serializer::pretty(&mut s); + data.serialize(&mut ser); + } + + String::from_utf8(s).or( + Err(ParserError::short("Cannot parse utf8 bytes", + String::from(""), + 0))) } }