From 933ecc0cd81c81c290dd233f4488b909e2b4b5fa Mon Sep 17 00:00:00 2001 From: Michail Klimenkov Date: Thu, 9 Jan 2025 19:09:35 +0000 Subject: [PATCH 1/4] updated dependencies, rkyv in particular --- Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index db3be06..d21bf02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,18 +12,18 @@ readme = "README.md" repository = "https://github.com/Synphonyte/codee" [dependencies] -base64 = { version = "0.21", optional = true } +base64 = { version = "0.22", optional = true } bincode = { version = "1", optional = true } js-sys = { version = "0.3", optional = true } miniserde = { version = "0.1", optional = true } -prost = { version = "0.12", optional = true } -rkyv = { version = "0.7", optional = true, features = ["validation", "strict"] } +prost = { version = "0.13", optional = true } +rkyv = { version = "0.8.9", optional = true } rmp-serde = { version = "1.1", optional = true } serde = { version = "1", optional = true } serde_json = { version = "1", optional = true } serde-lite = { version = "0.5", optional = true } serde-wasm-bindgen = { version = "0.6", optional = true } -thiserror = "1.0.61" +thiserror = "2.0" wasm-bindgen = { version = "0.2", optional = true } [features] @@ -38,8 +38,8 @@ json_serde_wasm = ["dep:serde", "dep:serde_json", "dep:js-sys", "dep:serde-wasm- [dev-dependencies] serde = { version = "1", features = ["derive"] } serde-lite = { version = "0.5", features = ["derive"] } -leptos = "0.6" -leptos-use = "0.12" +leptos = "0.7" +leptos-use = "0.15" [package.metadata.docs.rs] all-features = true \ No newline at end of file From 0c447f030fc3c6ffa9708ab59d18351da71e4dae Mon Sep 17 00:00:00 2001 From: Michail Klimenkov Date: Thu, 9 Jan 2025 20:20:00 +0000 Subject: [PATCH 2/4] rkyv 8 is now supported --- Cargo.toml | 4 ++-- src/binary/rkyv.rs | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d21bf02..6c7b89a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "codee" -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = ["Marc-Stefan Cassola"] categories = ["encoding"] @@ -17,7 +17,7 @@ bincode = { version = "1", optional = true } js-sys = { version = "0.3", optional = true } miniserde = { version = "0.1", optional = true } prost = { version = "0.13", optional = true } -rkyv = { version = "0.8.9", optional = true } +rkyv = { version = "0.8.9", optional = false } rmp-serde = { version = "1.1", optional = true } serde = { version = "1", optional = true } serde_json = { version = "1", optional = true } diff --git a/src/binary/rkyv.rs b/src/binary/rkyv.rs index b3e1ad1..790cdbc 100644 --- a/src/binary/rkyv.rs +++ b/src/binary/rkyv.rs @@ -1,10 +1,11 @@ use crate::{Decoder, Encoder}; -use rkyv::de::deserializers::SharedDeserializeMap; -use rkyv::ser::serializers::AllocSerializer; -use rkyv::validation::validators::DefaultValidator; -use rkyv::{Archive, CheckBytes, Deserialize, Fallible, Serialize}; use std::error::Error; use std::sync::Arc; +use rkyv::rancor::{Fallible, Strategy}; +use rkyv::ser::allocator::ArenaHandle; +use rkyv::{bytecheck, rancor, Archive, Deserialize, Serialize}; +use rkyv::api::high::{HighSerializer, HighValidator}; +use rkyv::de::Pool; /// A codec that relies on `rkyv` to encode data in the msgpack format. /// @@ -13,13 +14,13 @@ pub struct RkyvCodec; impl Encoder for RkyvCodec where - T: Serialize>, + T: for<'a> Serialize, ArenaHandle<'a>, rancor::Error>> { - type Error = as Fallible>::Error; + type Error = rancor::Error; type Encoded = Vec; fn encode(val: &T) -> Result { - Ok(rkyv::to_bytes::(val)?.to_vec()) + Ok(rkyv::api::high::to_bytes_in(val, Vec::new())?) } } @@ -27,13 +28,14 @@ impl Decoder for RkyvCodec where T: Archive, for<'a> T::Archived: - 'a + CheckBytes> + Deserialize, + 'a + bytecheck::CheckBytes> + Deserialize> + { type Error = Arc; type Encoded = [u8]; fn decode(val: &Self::Encoded) -> Result { - rkyv::from_bytes::(val).map_err(|e| Arc::new(e) as Arc) + rkyv::from_bytes::(val).map_err(|e| Arc::new(e) as Arc) } } @@ -44,7 +46,6 @@ mod tests { #[test] fn test_rkyv_codec() { #[derive(Clone, Debug, PartialEq, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] - #[archive(check_bytes)] struct Test { s: String, i: i32, From 518217da948cc1fda590df776b6c2058adcb5e94 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Thu, 9 Jan 2025 21:32:27 -0500 Subject: [PATCH 3/4] chore: rustfmt --- src/binary/rkyv.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/binary/rkyv.rs b/src/binary/rkyv.rs index 790cdbc..0bcdeb2 100644 --- a/src/binary/rkyv.rs +++ b/src/binary/rkyv.rs @@ -1,11 +1,11 @@ use crate::{Decoder, Encoder}; -use std::error::Error; -use std::sync::Arc; +use rkyv::api::high::{HighSerializer, HighValidator}; +use rkyv::de::Pool; use rkyv::rancor::{Fallible, Strategy}; use rkyv::ser::allocator::ArenaHandle; use rkyv::{bytecheck, rancor, Archive, Deserialize, Serialize}; -use rkyv::api::high::{HighSerializer, HighValidator}; -use rkyv::de::Pool; +use std::error::Error; +use std::sync::Arc; /// A codec that relies on `rkyv` to encode data in the msgpack format. /// @@ -14,7 +14,7 @@ pub struct RkyvCodec; impl Encoder for RkyvCodec where - T: for<'a> Serialize, ArenaHandle<'a>, rancor::Error>> + T: for<'a> Serialize, ArenaHandle<'a>, rancor::Error>>, { type Error = rancor::Error; type Encoded = Vec; @@ -27,9 +27,9 @@ where impl Decoder for RkyvCodec where T: Archive, - for<'a> T::Archived: - 'a + bytecheck::CheckBytes> + Deserialize> - + for<'a> T::Archived: 'a + + bytecheck::CheckBytes> + + Deserialize>, { type Error = Arc; type Encoded = [u8]; From e6aafe737db9dc3b4a485947ae18dc597203c9ba Mon Sep 17 00:00:00 2001 From: Maccesch Date: Thu, 9 Jan 2025 21:58:01 -0500 Subject: [PATCH 4/4] chore: clippy --- Cargo.toml | 2 +- src/binary/rkyv.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6c7b89a..4727ef7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ bincode = { version = "1", optional = true } js-sys = { version = "0.3", optional = true } miniserde = { version = "0.1", optional = true } prost = { version = "0.13", optional = true } -rkyv = { version = "0.8.9", optional = false } +rkyv = { version = "0.8.9", optional = true } rmp-serde = { version = "1.1", optional = true } serde = { version = "1", optional = true } serde_json = { version = "1", optional = true } diff --git a/src/binary/rkyv.rs b/src/binary/rkyv.rs index 0bcdeb2..8dd96ae 100644 --- a/src/binary/rkyv.rs +++ b/src/binary/rkyv.rs @@ -1,7 +1,7 @@ use crate::{Decoder, Encoder}; use rkyv::api::high::{HighSerializer, HighValidator}; use rkyv::de::Pool; -use rkyv::rancor::{Fallible, Strategy}; +use rkyv::rancor::Strategy; use rkyv::ser::allocator::ArenaHandle; use rkyv::{bytecheck, rancor, Archive, Deserialize, Serialize}; use std::error::Error; @@ -20,7 +20,7 @@ where type Encoded = Vec; fn encode(val: &T) -> Result { - Ok(rkyv::api::high::to_bytes_in(val, Vec::new())?) + rkyv::api::high::to_bytes_in(val, Vec::new()) } }