Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps #963

Merged
merged 2 commits into from
Mar 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ tempfile = "3.5.0"
redb1 = { version = "=1.0.0", package = "redb" }
# for backwards compatibility testing - pin at 2.0.0
redb2 = { version = "=2.0.0", package = "redb" }
serde = { version = "1.0", features = ["derive"] }
bincode = "1.3.3"
bincode = "2.0.1"
walkdir = "2.5.0"
byte-unit = "5.1.6"
fastrand = "2.0.0"
Expand All @@ -51,7 +50,7 @@ fjall = "2.6"
comfy-table = "7.0.1"

[target.'cfg(target_os = "linux")'.dev-dependencies]
io-uring = "0.6.2"
io-uring = "0.7.4"

[features]
# This feature is still experimental, and is not considered stable
Expand Down
17 changes: 9 additions & 8 deletions examples/bincode_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ use std::any::type_name;
use std::cmp::Ordering;
use std::fmt::Debug;

use bincode::{deserialize, serialize};
use bincode::{Decode, Encode, decode_from_slice, encode_to_vec};
use redb::{Database, Error, Key, Range, TableDefinition, TypeName, Value};
use serde::{Deserialize, Serialize, de::DeserializeOwned};

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord)]
struct SomeKey {
foo: String,
bar: i32,
}

#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Decode, Encode, PartialEq)]
struct SomeValue {
foo: [f64; 3],
bar: bool,
Expand Down Expand Up @@ -64,7 +63,7 @@ pub struct Bincode<T>(pub T);

impl<T> Value for Bincode<T>
where
T: Debug + Serialize + for<'a> Deserialize<'a>,
T: Debug + Encode + Decode<()>,
{
type SelfType<'a>
= T
Expand All @@ -84,15 +83,17 @@ where
where
Self: 'a,
{
deserialize(data).unwrap()
decode_from_slice(data, bincode::config::standard())
.unwrap()
.0
}

fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Self::AsBytes<'a>
where
Self: 'a,
Self: 'b,
{
serialize(value).unwrap()
encode_to_vec(value, bincode::config::standard()).unwrap()
}

fn type_name() -> TypeName {
Expand All @@ -102,7 +103,7 @@ where

impl<T> Key for Bincode<T>
where
T: Debug + Serialize + DeserializeOwned + Ord,
T: Debug + Decode<()> + Encode + Ord,
{
fn compare(data1: &[u8], data2: &[u8]) -> Ordering {
Self::from_bytes(data1).cmp(&Self::from_bytes(data2))
Expand Down