From 1e4b2e0adbfc0646e922209ef69d7492dbcd94a3 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Tue, 3 Jan 2023 06:58:54 -0500 Subject: [PATCH] use serde_json's to_writer --- src/helpers/json.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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