Skip to content

Commit

Permalink
Merge pull request #53 from darach/cache-status-serde-fix
Browse files Browse the repository at this point in the history
Fix serialization issues for CacheStatus on dataset query response
  • Loading branch information
bahlo authored Nov 30, 2023
2 parents 2ff71b7 + 05ce40e commit 11c0897
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ url = "2"
tracing = { version = "0.1" }
tokio-stream = "0.1"
bitflags = "2"
bitflags_serde_shim = "0.2.4"

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
Expand Down
21 changes: 2 additions & 19 deletions src/datasets/model.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bitflags::bitflags;
use bitflags_serde_shim::impl_serde_for_bitflags;
use chrono::{DateTime, Duration, Utc};
use http::header::HeaderValue;
use serde::{
Expand Down Expand Up @@ -888,25 +889,7 @@ bitflags! {
const WalCached = 8; // WAL is cached
}
}

impl Serialize for CacheStatus {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_u32((*self).bits())
}
}

impl<'de> Deserialize<'de> for CacheStatus {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value: u32 = Deserialize::deserialize(deserializer)?;
Ok(Self::from_bits(value).unwrap_or_default())
}
}
impl_serde_for_bitflags!(CacheStatus);

/// A message that is returned in the status of a query.
#[derive(Serialize, Deserialize, Debug)]
Expand Down

0 comments on commit 11c0897

Please sign in to comment.