diff --git a/Cargo.toml b/Cargo.toml index ab4b045c48..83d7dd8cf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,11 @@ rkyv-16 = ["dep:rkyv", "rkyv?/size_16"] rkyv-32 = ["dep:rkyv", "rkyv?/size_32"] rkyv-64 = ["dep:rkyv", "rkyv?/size_64"] rkyv-validation = ["rkyv?/validation"] +rkyv-08 = ["dep:rkyv-08", "rkyv-08/pointer_width_32"] +rkyv-08-16 = ["dep:rkyv-08", "rkyv-08/pointer_width_16"] +rkyv-08-32 = ["dep:rkyv-08", "rkyv-08/pointer_width_32"] +rkyv-08-64 = ["dep:rkyv-08", "rkyv-08/pointer_width_64"] +rkyv-08-bytecheck = ["rkyv-08/bytecheck"] # Features for internal use only: __internal_bench = [] @@ -42,6 +47,7 @@ num-traits = { version = "0.2", default-features = false } serde = { version = "1.0.99", default-features = false, optional = true } pure-rust-locales = { version = "0.8", optional = true } rkyv = { version = "0.7.43", optional = true, default-features = false } +rkyv-08 = { package = "rkyv", version = "0.8.8", optional = true, default-features = false } arbitrary = { version = "1.0.0", features = ["derive"], optional = true } [target.'cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))'.dependencies] diff --git a/src/datetime/mod.rs b/src/datetime/mod.rs index f463c2ab5b..d0d2aed1f8 100644 --- a/src/datetime/mod.rs +++ b/src/datetime/mod.rs @@ -34,6 +34,9 @@ use crate::{Datelike, Months, TimeDelta, Timelike, Weekday}; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + /// documented at re-export site #[cfg(feature = "serde")] pub(super) mod serde; @@ -52,6 +55,11 @@ mod tests; derive(Archive, Deserialize, Serialize), archive(compare(PartialEq, PartialOrd)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv(crate = rkyv_08, compare(PartialEq, PartialOrd)) +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] pub struct DateTime { datetime: NaiveDateTime, @@ -1770,7 +1778,7 @@ impl fmt::Debug for DateTime { // * https://github.com/rust-lang/rust/issues/26925 // * https://github.com/rkyv/rkyv/issues/333 // * https://github.com/dtolnay/syn/issues/370 -#[cfg(feature = "rkyv-validation")] +#[cfg(any(feature = "rkyv-validation", feature = "rkyv-08-bytecheck"))] impl fmt::Debug for ArchivedDateTime where Tz: Archive, diff --git a/src/month.rs b/src/month.rs index f8033fccd6..914f95afb7 100644 --- a/src/month.rs +++ b/src/month.rs @@ -3,6 +3,9 @@ use core::fmt; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + use crate::OutOfRange; /// The month of the year. @@ -35,6 +38,15 @@ use crate::OutOfRange; archive(compare(PartialEq, PartialOrd)), archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq, PartialOrd), + derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] #[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))] pub enum Month { @@ -439,4 +451,12 @@ mod tests { let bytes = rkyv::to_bytes::<_, 1>(&month).unwrap(); assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), month); } + + #[test] + #[cfg(feature = "rkyv-08-bytecheck")] + fn test_rkyv_08_bytecheck() { + let month = Month::January; + let bytes = rkyv_08::to_bytes::(&month).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), month); + } } diff --git a/src/naive/date/mod.rs b/src/naive/date/mod.rs index bd70d52b31..d13512fc58 100644 --- a/src/naive/date/mod.rs +++ b/src/naive/date/mod.rs @@ -23,6 +23,9 @@ use core::{fmt, str}; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + /// L10n locales. #[cfg(all(feature = "unstable-locales", feature = "alloc"))] use pure_rust_locales::Locale; @@ -98,6 +101,15 @@ mod tests; archive(compare(PartialEq, PartialOrd)), archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq, PartialOrd), + derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] pub struct NaiveDate { yof: NonZeroI32, // (year << 13) | of diff --git a/src/naive/date/tests.rs b/src/naive/date/tests.rs index 6ae6867fc1..87400dee42 100644 --- a/src/naive/date/tests.rs +++ b/src/naive/date/tests.rs @@ -862,6 +862,18 @@ fn test_rkyv_validation() { assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), date_max); } +#[test] +#[cfg(feature = "rkyv-08-bytecheck")] +fn test_rkyv_validation() { + let date_min = NaiveDate::MIN; + let bytes = rkyv_08::to_bytes::(&date_min).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), date_min); + + let date_max = NaiveDate::MAX; + let bytes = rkyv_08::to_bytes::(&date_max).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), date_max); +} + // MAX_YEAR-12-31 minus 0000-01-01 // = (MAX_YEAR-12-31 minus 0000-12-31) + (0000-12-31 - 0000-01-01) // = MAX_YEAR * 365 + (# of leap years from 0001 to MAX_YEAR) + 365 diff --git a/src/naive/datetime/mod.rs b/src/naive/datetime/mod.rs index a2ffc69674..d3ba9bd051 100644 --- a/src/naive/datetime/mod.rs +++ b/src/naive/datetime/mod.rs @@ -13,6 +13,9 @@ use core::{fmt, str}; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + #[cfg(feature = "alloc")] use crate::format::DelayedFormat; use crate::format::{parse, parse_and_remainder, ParseError, ParseResult, Parsed, StrftimeItems}; @@ -71,6 +74,15 @@ pub const MAX_DATETIME: NaiveDateTime = NaiveDateTime::MAX; archive(compare(PartialEq, PartialOrd)), archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq, PartialOrd), + derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] #[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))] pub struct NaiveDateTime { diff --git a/src/naive/datetime/tests.rs b/src/naive/datetime/tests.rs index 161245813d..441ce030c3 100644 --- a/src/naive/datetime/tests.rs +++ b/src/naive/datetime/tests.rs @@ -407,3 +407,15 @@ fn test_rkyv_validation() { let bytes = rkyv::to_bytes::<_, 12>(&dt_max).unwrap(); assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), dt_max); } + +#[test] +#[cfg(feature = "rkyv-08-bytecheck")] +fn test_rkyv_validation() { + let dt_min = NaiveDateTime::MIN; + let bytes = rkyv_08::to_bytes::(&dt_min).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), dt_min); + + let dt_max = NaiveDateTime::MAX; + let bytes = rkyv_08::to_bytes::(&dt_max).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), dt_max); +} diff --git a/src/naive/isoweek.rs b/src/naive/isoweek.rs index 93d0dc423f..ececef91e8 100644 --- a/src/naive/isoweek.rs +++ b/src/naive/isoweek.rs @@ -10,6 +10,9 @@ use super::internals::YearFlags; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + /// ISO 8601 week. /// /// This type, combined with [`Weekday`](../enum.Weekday.html), @@ -23,6 +26,15 @@ use rkyv::{Archive, Deserialize, Serialize}; archive(compare(PartialEq, PartialOrd)), archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq, PartialOrd), + derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] pub struct IsoWeek { // Note that this allows for larger year range than `NaiveDate`. @@ -162,7 +174,7 @@ impl fmt::Debug for IsoWeek { #[cfg(test)] mod tests { - #[cfg(feature = "rkyv-validation")] + #[cfg(any(feature = "rkyv-validation", feature = "rkyv-08-bytecheck"))] use super::IsoWeek; use crate::naive::date::{self, NaiveDate}; use crate::Datelike; @@ -230,4 +242,16 @@ mod tests { let bytes = rkyv::to_bytes::<_, 4>(&maxweek).unwrap(); assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), maxweek); } + + #[test] + #[cfg(feature = "rkyv-08-bytecheck")] + fn test_rkyv_bytecheck() { + let minweek = NaiveDate::MIN.iso_week(); + let bytes = rkyv_08::to_bytes::(&minweek).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), minweek); + + let maxweek = NaiveDate::MAX.iso_week(); + let bytes = rkyv_08::to_bytes::(&maxweek).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), maxweek); + } } diff --git a/src/naive/time/mod.rs b/src/naive/time/mod.rs index f32d828080..2895d16553 100644 --- a/src/naive/time/mod.rs +++ b/src/naive/time/mod.rs @@ -12,6 +12,9 @@ use core::{fmt, str}; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + #[cfg(feature = "alloc")] use crate::format::DelayedFormat; use crate::format::{ @@ -216,6 +219,15 @@ mod tests; archive(compare(PartialEq, PartialOrd)), archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq, PartialOrd), + derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] pub struct NaiveTime { secs: u32, diff --git a/src/naive/time/tests.rs b/src/naive/time/tests.rs index a8754aebd6..5cf881103f 100644 --- a/src/naive/time/tests.rs +++ b/src/naive/time/tests.rs @@ -391,3 +391,15 @@ fn test_rkyv_validation() { let bytes = rkyv::to_bytes::<_, 8>(&t_max).unwrap(); assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), t_max); } + +#[test] +#[cfg(feature = "rkyv-08-bytecheck")] +fn test_rkyv_bytecheck() { + let t_min = NaiveTime::MIN; + let bytes = rkyv_08::to_bytes::(&t_min).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), t_min); + + let t_max = NaiveTime::MAX; + let bytes = rkyv_08::to_bytes::(&t_max).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), t_max); +} diff --git a/src/offset/fixed.rs b/src/offset/fixed.rs index e7382bed1d..0dae1ab33b 100644 --- a/src/offset/fixed.rs +++ b/src/offset/fixed.rs @@ -9,6 +9,9 @@ use core::str::FromStr; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + use super::{MappedLocalTime, Offset, TimeZone}; use crate::format::{scan, ParseError, OUT_OF_RANGE}; use crate::naive::{NaiveDate, NaiveDateTime}; @@ -26,6 +29,15 @@ use crate::naive::{NaiveDate, NaiveDateTime}; archive(compare(PartialEq)), archive_attr(derive(Clone, Copy, PartialEq, Eq, Hash, Debug)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq), + derive(Clone, Copy, PartialEq, Eq, Hash, Debug), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] pub struct FixedOffset { local_minus_utc: i32, @@ -233,4 +245,12 @@ mod tests { let bytes = rkyv::to_bytes::<_, 4>(&offset).unwrap(); assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), offset); } + + #[test] + #[cfg(feature = "rkyv-08-bytecheck")] + fn test_rkyv_bytecheck() { + let offset = FixedOffset::from_str("-0500").unwrap(); + let bytes = rkyv_08::to_bytes::(&offset).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), offset); + } } diff --git a/src/offset/local/mod.rs b/src/offset/local/mod.rs index 611fe18d8d..0725ebdfd4 100644 --- a/src/offset/local/mod.rs +++ b/src/offset/local/mod.rs @@ -9,6 +9,9 @@ use std::cmp::Ordering; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + use super::fixed::FixedOffset; use super::{MappedLocalTime, TimeZone}; use crate::naive::{NaiveDate, NaiveDateTime, NaiveTime}; @@ -117,6 +120,15 @@ mod tz_info; archive(compare(PartialEq)), archive_attr(derive(Clone, Copy, Debug)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq), + derive(Clone, Copy, Debug), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct Local; @@ -538,4 +550,17 @@ mod tests { // wrapping object assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), super::ArchivedLocal); } + + #[test] + #[cfg(feature = "rkyv-08-bytecheck")] + fn test_rkyv_bytecheck() { + let local = Local; + // Local is a ZST and serializes to 0 bytes + let bytes = rkyv_08::to_bytes::(&local).unwrap(); + assert_eq!(bytes.len(), 0); + + // but is deserialized to an archived variant without a + // wrapping object + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), super::ArchivedLocal); + } } diff --git a/src/offset/utc.rs b/src/offset/utc.rs index 5ae26ed86d..f7ebe9445a 100644 --- a/src/offset/utc.rs +++ b/src/offset/utc.rs @@ -17,6 +17,9 @@ use std::time::{SystemTime, UNIX_EPOCH}; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + use super::{FixedOffset, MappedLocalTime, Offset, TimeZone}; use crate::naive::{NaiveDate, NaiveDateTime}; #[cfg(feature = "now")] @@ -47,6 +50,15 @@ use crate::{Date, DateTime}; archive(compare(PartialEq)), archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq), + derive(Clone, Copy, PartialEq, Eq, Debug, Hash), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] #[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))] pub struct Utc; diff --git a/src/time_delta.rs b/src/time_delta.rs index d030689695..3b0346ffbd 100644 --- a/src/time_delta.rs +++ b/src/time_delta.rs @@ -21,6 +21,9 @@ use crate::{expect, try_opt}; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + /// The number of nanoseconds in a microsecond. const NANOS_PER_MICRO: i32 = 1000; /// The number of nanoseconds in a millisecond. @@ -56,6 +59,15 @@ const SECS_PER_WEEK: i64 = 604_800; archive(compare(PartialEq, PartialOrd)), archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq, PartialOrd), + derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] pub struct TimeDelta { secs: i64, @@ -1346,4 +1358,12 @@ mod tests { let bytes = rkyv::to_bytes::<_, 16>(&duration).unwrap(); assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), duration); } + + #[test] + #[cfg(feature = "rkyv-08-bytecheck")] + fn test_rkyv_bytecheck() { + let duration = TimeDelta::try_seconds(1).unwrap(); + let bytes = rkyv_08::to_bytes::(&duration).unwrap(); + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), duration); + } } diff --git a/src/weekday.rs b/src/weekday.rs index f41b5845cf..aec88e1c06 100644 --- a/src/weekday.rs +++ b/src/weekday.rs @@ -3,6 +3,9 @@ use core::fmt; #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; +#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))] +use rkyv_08::{Archive, Deserialize, Serialize}; + use crate::OutOfRange; /// The day of week. @@ -36,6 +39,15 @@ use crate::OutOfRange; archive(compare(PartialEq)), archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash)) )] +#[cfg_attr( + any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"), + derive(Archive, Deserialize, Serialize), + rkyv( + crate = rkyv_08, + compare(PartialEq), + derive(Clone, Copy, PartialEq, Eq, Debug, Hash), + ), +)] #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))] #[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))] pub enum Weekday { @@ -399,4 +411,13 @@ mod tests { assert_eq!(rkyv::from_bytes::(&bytes).unwrap(), mon); } + + #[test] + #[cfg(feature = "rkyv-08-bytecheck")] + fn test_rkyv_bytecheck() { + let mon = Weekday::Mon; + let bytes = rkyv_08::to_bytes::(&mon).unwrap(); + + assert_eq!(rkyv_08::from_bytes::(&bytes).unwrap(), mon); + } }