Skip to content

Commit

Permalink
Merge pull request #273 from redbadger/serde_bytes-in-crux_kv
Browse files Browse the repository at this point in the history
use serde_bytes in crux_kv
  • Loading branch information
StuartHarris authored Oct 18, 2024
2 parents d33963c + 98fc11d commit a9f5bc6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crux_kv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ typegen = []
anyhow.workspace = true
crux_core = { version = "0.9.0", path = "../crux_core" }
serde = { workspace = true, features = ["derive"] }
serde_bytes = "0.11.15"
thiserror = "1.0.63"
6 changes: 5 additions & 1 deletion crux_kv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ pub enum KeyValueOperation {
/// Read bytes stored under a key
Get { key: String },
/// Write bytes under a key
Set { key: String, value: Vec<u8> },
Set {
key: String,
#[serde(with = "serde_bytes")]
value: Vec<u8>,
},
/// Remove a key and its value
Delete { key: String },
/// Test if a key exists
Expand Down
2 changes: 1 addition & 1 deletion crux_kv/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
pub enum Value {
None,
Bytes(Vec<u8>),
Bytes(#[serde(with = "serde_bytes")] Vec<u8>),
}

impl From<Vec<u8>> for Value {
Expand Down

0 comments on commit a9f5bc6

Please sign in to comment.