diff --git a/Cargo.lock b/Cargo.lock index c6b362c94..afaab1153 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -420,6 +420,7 @@ dependencies = [ "anyhow", "crux_core", "serde", + "serde_bytes", "thiserror", ] diff --git a/crux_kv/Cargo.toml b/crux_kv/Cargo.toml index f8f492de3..737fbbbc0 100644 --- a/crux_kv/Cargo.toml +++ b/crux_kv/Cargo.toml @@ -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" diff --git a/crux_kv/src/lib.rs b/crux_kv/src/lib.rs index 06fa03a22..0cd92cb35 100644 --- a/crux_kv/src/lib.rs +++ b/crux_kv/src/lib.rs @@ -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 }, + Set { + key: String, + #[serde(with = "serde_bytes")] + value: Vec, + }, /// Remove a key and its value Delete { key: String }, /// Test if a key exists diff --git a/crux_kv/src/value.rs b/crux_kv/src/value.rs index 0e83bfbba..cbfd8cd09 100644 --- a/crux_kv/src/value.rs +++ b/crux_kv/src/value.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)] pub enum Value { None, - Bytes(Vec), + Bytes(#[serde(with = "serde_bytes")] Vec), } impl From> for Value {