Skip to content

Commit

Permalink
chore(core): use serde_json::to_vec instead
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Jun 9, 2024
1 parent a3510d9 commit f5e46a3
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions viz-core/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,8 @@ pub trait ResponseExt: private::Sealed + Sized {
where
T: serde::Serialize,
{
use bytes::{BufMut, BytesMut};

// See <https://docs.rs/serde_json/latest/src/serde_json/ser.rs.html#2179>
let mut buf = BytesMut::with_capacity(128).writer();
serde_json::to_writer(&mut buf, &body)
.map(|()| {
Self::with(
Full::new(buf.into_inner().freeze()),
mime::APPLICATION_JSON.as_ref(),
)
})
serde_json::to_vec(&body)
.map(|buf| Self::with(Full::new(buf.into()), mime::APPLICATION_JSON.as_ref()))
.map_err(crate::types::PayloadError::Json)
}

Expand Down

0 comments on commit f5e46a3

Please sign in to comment.