Skip to content

Commit

Permalink
bincode -> json (#27)
Browse files Browse the repository at this point in the history
* bincode -> json

Signed-off-by: andrewmatilde <[email protected]>

* fix lint

Signed-off-by: andrewmatilde <[email protected]>
  • Loading branch information
Andrewmatilde authored Dec 9, 2021
1 parent 88022e5 commit 1e7ab42
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rs-tproxy-controller/src/proxy/uds_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<T: serde::ser::Serialize> UdsDataServer<T> {
loop {
match (&listener).accept().await {
Ok((mut stream, addr)) => {
let buf = bincode::serialize(&self.data)?;
let buf = serde_json::to_vec(&self.data)?;
tokio::spawn(async move {
return match stream.write_all(buf.as_slice()).await {
Ok(_) => {
Expand Down
4 changes: 2 additions & 2 deletions rs-tproxy-proxy/src/handler/http/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub async fn apply_request_action(
append_queries(request.uri_mut(), patch.queries.as_ref())?;
if let Some(patch_body) = &patch.body {
let PatchBodyActionContents::JSON(ref value) = patch_body.contents;
let mut data = read_value(&mut request.body_mut()).await?;
let mut data = read_value(request.body_mut()).await?;
json_patch::merge(&mut data, value);
let merged = serde_json::to_vec(&data)?;
*request.body_mut() = merged.into();
Expand Down Expand Up @@ -216,7 +216,7 @@ pub async fn apply_response_action(
if let Some(patch) = &actions.patch {
if let Some(patch_body) = &patch.body {
let PatchBodyActionContents::JSON(ref value) = patch_body.contents;
let mut data = read_value(&mut response.body_mut()).await?;
let mut data = read_value(response.body_mut()).await?;
json_patch::merge(&mut data, value);
let merged = serde_json::to_vec(&data)?;
*response.body_mut() = merged.into();
Expand Down
2 changes: 1 addition & 1 deletion rs-tproxy-proxy/src/uds_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl UdsDataClient {
Ok(_) => {
tracing::debug!("Read data successfully.");

match bincode::deserialize(buf.as_slice()) {
match serde_json::from_slice(buf.as_slice()) {
Ok(o) => {
tracing::debug!("Deserialize data successfully.");
Ok(o)
Expand Down

0 comments on commit 1e7ab42

Please sign in to comment.