From ac6223fe50c88af8ff8f51e5e299e73b72f40509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sobieraj-Jakubiec?= Date: Mon, 5 Jan 2026 13:53:51 +0100 Subject: [PATCH] chore: update rkyv >= 0.8.13 --- Cargo.toml | 5 ++--- examples/rkyv-remote.rs | 2 -- src/decimal.rs | 5 ++--- tests/decimal_tests.rs | 10 +++++----- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b5b991f6..9011e7c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ proptest = { default-features = false, optional = true, features = ["std"], vers rand = { default-features = false, optional = true, version = "0.8" } rand-0_9 = { default-features = false, optional = true, package = "rand", version = "0.9" } rust_decimal_macros = { path = "macros", default-features = false, optional = true, version = "1" } -rkyv = { default-features = false, features = ["size_32", "std"], optional = true, version = "0.7.42" } +rkyv = { default-features = false, features = ["pointer_width_32"], optional = true, version = "0.8.13" } rocket = { default-features = false, optional = true, version = "0.5.0-rc.3" } ryu = { default-features = false, optional = true, version = "1.0" } serde = { default-features = false, optional = true, version = "1.0" } @@ -47,7 +47,6 @@ diesel = { default-features = false, features = ["mysql", "postgres"], version = futures = { default-features = false, version = "0.3" } rand = { default-features = false, features = ["getrandom"], version = "0.8" } rand-0_9 = { default-features = false, features = ["thread_rng"], package = "rand", version = "0.9" } -rkyv-0_8 = { version = "0.8", package = "rkyv" } rust_decimal_macros = { path = "macros" } serde = { default-features = false, features = ["derive"], version = "1.0" } serde_json = "1.0" @@ -76,7 +75,7 @@ ndarray = ["dep:ndarray"] proptest = ["dep:proptest"] rand = ["dep:rand"] rkyv = ["dep:rkyv"] -rkyv-safe = ["rkyv/validation"] +rkyv-safe = ["rkyv/bytecheck"] rocket-traits = ["dep:rocket", "std"] rust-fuzz = ["dep:arbitrary"] serde = ["dep:serde"] diff --git a/examples/rkyv-remote.rs b/examples/rkyv-remote.rs index c5473fda..8fccf296 100644 --- a/examples/rkyv-remote.rs +++ b/examples/rkyv-remote.rs @@ -1,5 +1,3 @@ -extern crate rkyv_0_8 as rkyv; - use rkyv::{rancor::Error, Archive, Deserialize, Serialize}; use rust_decimal::prelude::{dec, Decimal}; diff --git a/src/decimal.rs b/src/decimal.rs index 4ec60312..4243d60e 100644 --- a/src/decimal.rs +++ b/src/decimal.rs @@ -109,10 +109,9 @@ pub struct UnpackedDecimal { #[cfg_attr( feature = "rkyv", derive(Archive, Deserialize, Serialize), - archive(compare(PartialEq)), - archive_attr(derive(Clone, Copy, Debug)) + rkyv(compare(PartialEq), derive(Clone, Copy, Debug)) )] -#[cfg_attr(feature = "rkyv-safe", archive(check_bytes))] +#[cfg_attr(feature = "rkyv-safe", rkyv(bytecheck()))] pub struct Decimal { // Bits 0-15: unused // Bits 16-23: Contains "e", a value between 0-28 that indicates the scale diff --git a/tests/decimal_tests.rs b/tests/decimal_tests.rs index 28a275b9..2324c794 100644 --- a/tests/decimal_tests.rs +++ b/tests/decimal_tests.rs @@ -220,12 +220,12 @@ mod ndarray_tests { #[cfg(feature = "rkyv")] mod rkyv_tests { + use rkyv::rancor::Error; use rust_decimal::Decimal; use std::str::FromStr; #[test] fn it_can_serialize_deserialize_rkyv() { - use rkyv::Deserialize; let tests = [ "12.3456789", "5233.9008808150288439427720175", @@ -233,18 +233,18 @@ mod rkyv_tests { ]; for test in &tests { let a = Decimal::from_str(test).unwrap(); - let bytes = rkyv::to_bytes::<_, 256>(&a).unwrap(); + let bytes = rkyv::to_bytes::(&a).unwrap(); #[cfg(feature = "rkyv-safe")] { - let archived = rkyv::check_archived_root::(&bytes[..]).unwrap(); + let archived = rkyv::access::<::Archived, Error>(&bytes[..]).unwrap(); assert_eq!(archived, &a); } - let archived = unsafe { rkyv::archived_root::(&bytes[..]) }; + let archived = unsafe { rkyv::access_unchecked::<::Archived>(&bytes[..]) }; assert_eq!(archived, &a); - let deserialized: Decimal = archived.deserialize(&mut rkyv::Infallible).unwrap(); + let deserialized: Decimal = rkyv::deserialize::(archived).unwrap(); assert_eq!(deserialized, a); } }