mirror of
https://github.com/stoatchat/iso8601-timestamp.git
synced 2026-07-01 21:45:22 -04:00
Improve rkyv support
This commit is contained in:
+2
-2
@@ -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
@@ -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
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user