Skip to content

Commit cbc85f9

Browse files
unhappychoiceclaude
andcommitted
fix: update bincode API calls for v2.0 compatibility
- Enable serde feature for bincode in Cargo.toml - Replace bincode::serialize with bincode::serde::encode_to_vec - Replace bincode::deserialize with bincode::serde::decode_from_slice - Handle tuple return value from decode_from_slice 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 649b886 commit cbc85f9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ tempfile = "3.22"
7272
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
7373
reqwest = { version = "0.12", features = ["json"] }
7474
atty = "0.2"
75-
bincode = "2.0"
75+
bincode = { version = "2.0", features = ["serde"] }
7676
flate2 = "1.0"
7777
sha2 = "0.10"
7878

src/cache/gzip_storage.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ pub struct GzipStorage;
77

88
impl GzipStorage {
99
pub fn save<T: serde::Serialize>(path: &std::path::Path, data: &T) -> Result<(), String> {
10-
let binary_data =
11-
bincode::serialize(data).map_err(|e| format!("Failed to serialize data: {}", e))?;
10+
let binary_data = bincode::serde::encode_to_vec(data, bincode::config::standard())
11+
.map_err(|e| format!("Failed to serialize data: {}", e))?;
1212
let mut encoder = GzEncoder::new(Vec::new(), Compression::default());
1313
encoder
1414
.write_all(&binary_data)
@@ -27,6 +27,8 @@ impl GzipStorage {
2727

2828
decoder.read_to_end(&mut binary_data).ok()?;
2929

30-
bincode::deserialize(&binary_data).ok()
30+
bincode::serde::decode_from_slice(&binary_data, bincode::config::standard())
31+
.ok()
32+
.map(|(data, _)| data)
3133
}
3234
}

0 commit comments

Comments
 (0)