Skip to content

Commit

Permalink
use combined branch
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed May 26, 2024
1 parent e23f38e commit 9c97790
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ scraper = { git = "https://github.com/causal-agent/scraper.git", rev = "d67111f5
tokio-postgres-rustls = { git = "https://github.com/jbg/tokio-postgres-rustls.git", rev = "b16c1bc0f5d4f91324174fd1bd839d743a70f86a" }

# SIMD runtime detection
sonic-rs = { git = "https://github.com/cloudwego/sonic-rs.git", rev = "8808ec64ce198a65b525cba07306aef499862777" }
sonic-rs = { git = "https://github.com/cloudwego/sonic-rs.git", rev = "d1f172d75e7c9386fde169673d2666e0cfd5d32c" }

# TCP nodelay for `axum::serve`
axum = { git = "https://github.com/tokio-rs/axum.git", rev = "8d0c5c05eb75eb779591c8000705e785123868a0" }
Expand Down
13 changes: 6 additions & 7 deletions crates/kitsune-db/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use diesel::{
AsExpression, FromSqlRow,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use sonic_rs::writer::BufferedWriter;
use std::{
error::Error,
fmt::{self, Debug},
Expand Down Expand Up @@ -48,6 +49,7 @@ impl<T> FromSql<Jsonb, Pg> for Json<T>
where
T: DeserializeOwned,
{
#[inline]
fn from_sql(bytes: <Pg as Backend>::RawValue<'_>) -> deserialize::Result<Self> {
let bytes = bytes.as_bytes();
if bytes[0] != 1 {
Expand All @@ -61,14 +63,11 @@ impl<T> ToSql<Jsonb, Pg> for Json<T>
where
T: Debug + Serialize,
{
#[inline]
fn to_sql<'b>(&'b self, out: &mut serialize::Output<'b, '_, Pg>) -> serialize::Result {
out.write_all(&[1])?;

// TODO: Intermediate buffering for now. Remove once sonic-rs gets the ability to skip this
// See: <https://github.com/cloudwego/sonic-rs/issues/54>
let vec = sonic_rs::to_vec(self)?;
out.write_all(&vec)?;

Ok(IsNull::No)
sonic_rs::to_writer(BufferedWriter::new(out), self)

Check warning on line 69 in crates/kitsune-db/src/json.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-db/src/json.rs#L69

Added line #L69 was not covered by tests
.map(|()| IsNull::No)
.map_err(Into::into)
}
}

0 comments on commit 9c97790

Please sign in to comment.