diff --git a/src/helpers/json.rs b/src/helpers/json.rs index ea0cb43..bfa23f7 100644 --- a/src/helpers/json.rs +++ b/src/helpers/json.rs @@ -46,13 +46,7 @@ pub fn to_vec(data: &Data) -> Result> { /// Attempts to serialize a Data struct to something that implements the /// std::io::Write trait pub fn to_writer(data: &Data, writer: W) -> Result<()> { - let mut buf_writer = BufWriter::new(writer); - let vec = to_vec(data)?; - if vec.len() != buf_writer.write(&vec)? { - Err(crate::Error::NotAllBytesWritten) - } else { - Ok(()) - } + Ok(serde_json::to_writer(data, writer)?) } /// Attempts to serialize a Data struct to a file