diff --git a/Cargo.toml b/Cargo.toml index db3be06..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"] @@ -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 = false } 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 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,