Improve rkyv support

This commit is contained in:
novacrazy
2023-12-05 07:30:57 -06:00
parent bd0797ed7b
commit 5bbae7256c
3 changed files with 13 additions and 4 deletions
+2 -2
View File
@@ -44,7 +44,7 @@ quickcheck = { optional = true, version = "1.0", default-features = false }
worker = { optional = true, version = "0.0.18" }
js-sys = { optional = true, version = "0.3" }
ramhorns = { optional = true, version = "0.14" }
rkyv = { optional = true, version = "0.7" }
rkyv = { optional = true, version = "0.7", default-features = false, features = ["validation"] }
[dev-dependencies]
time = { version = "0.3", features = ["macros", "parsing", "formatting"] }
@@ -53,7 +53,7 @@ chrono = "0.4"
iso8601 = "0.6"
ciborium = "0.2"
serde = { version = "1", features = ["derive"] }
rkyv = { version = "0.7", features = ["validation"] }
rkyv = { version = "0.7", default-features = true }
[[bench]]
name = "timestamp"
+10 -1
View File
@@ -836,7 +836,16 @@ pub struct ArchivedTimestamp(pub i64);
mod rkyv_impl {
use super::{ArchivedTimestamp, Duration, Timestamp};
use rkyv::{Archive, Archived, Deserialize, Fallible, Serialize};
use rkyv::{Archive, Archived, CheckBytes, Deserialize, Fallible, Serialize};
impl<C: ?Sized> CheckBytes<C> for ArchivedTimestamp {
type Error = <i64 as CheckBytes<C>>::Error;
#[inline]
unsafe fn check_bytes<'a>(value: *const Self, _context: &mut C) -> Result<&'a Self, Self::Error> {
Ok(&*value)
}
}
impl Archive for Timestamp {
type Archived = ArchivedTimestamp;
+1 -1
View File
@@ -20,7 +20,7 @@ fn test_rkyv() {
let buf = ser.into_serializer().into_inner();
let archived_value = check_archived_root::<Timestamp>(&buf).unwrap();
println!("{}", archived_value);
println!("{:?}", archived_value);
let de = archived_value.deserialize(&mut Infallible).unwrap();