From e920210e2f94ad85ff25c30ae902442d4e2872c2 Mon Sep 17 00:00:00 2001 From: Weiyuan Wu Date: Tue, 7 Jun 2022 01:51:02 +0000 Subject: [PATCH] add missing rkyv derives --- src/datetime/mod.rs | 4 ++++ src/month.rs | 4 ++++ src/naive/isoweek.rs | 4 ++++ src/oldtime.rs | 4 ++++ src/weekday.rs | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/src/datetime/mod.rs b/src/datetime/mod.rs index fe41b4cc..ab924a92 100644 --- a/src/datetime/mod.rs +++ b/src/datetime/mod.rs @@ -32,6 +32,9 @@ use crate::oldtime::Duration as OldDuration; use crate::Date; use crate::{Datelike, Timelike, Weekday}; +#[cfg(feature = "rkyv")] +use rkyv::{Archive, Deserialize, Serialize}; + #[cfg(feature = "rustc-serialize")] pub(super) mod rustc_serialize; @@ -79,6 +82,7 @@ pub enum SecondsFormat { /// the general-purpose constructors are all via the methods on the /// [`TimeZone`](./offset/trait.TimeZone.html) implementations. #[derive(Clone)] +#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))] pub struct DateTime { datetime: NaiveDateTime, offset: Tz::Offset, diff --git a/src/month.rs b/src/month.rs index a87fe51e..7b642f9e 100644 --- a/src/month.rs +++ b/src/month.rs @@ -1,5 +1,8 @@ use core::fmt; +#[cfg(feature = "rkyv")] +use rkyv::{Archive, Deserialize, Serialize}; + /// The month of the year. /// /// This enum is just a convenience implementation. @@ -26,6 +29,7 @@ use core::fmt; // Actual implementation is zero-indexed, API intended as 1-indexed for more intuitive behavior. #[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)] #[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))] +#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))] pub enum Month { /// January January = 0, diff --git a/src/naive/isoweek.rs b/src/naive/isoweek.rs index 3cadf6b1..dbddb034 100644 --- a/src/naive/isoweek.rs +++ b/src/naive/isoweek.rs @@ -7,6 +7,9 @@ use core::fmt; use super::internals::{DateImpl, Of, YearFlags}; +#[cfg(feature = "rkyv")] +use rkyv::{Archive, Deserialize, Serialize}; + /// ISO 8601 week. /// /// This type, combined with [`Weekday`](../enum.Weekday.html), @@ -14,6 +17,7 @@ use super::internals::{DateImpl, Of, YearFlags}; /// One can retrieve this type from the existing [`Datelike`](../trait.Datelike.html) types /// via the [`Datelike::iso_week`](../trait.Datelike.html#tymethod.iso_week) method. #[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] +#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))] pub struct IsoWeek { // note that this allows for larger year range than `NaiveDate`. // this is crucial because we have an edge case for the first and last week supported, diff --git a/src/oldtime.rs b/src/oldtime.rs index 388b71a4..57d199e2 100644 --- a/src/oldtime.rs +++ b/src/oldtime.rs @@ -16,6 +16,9 @@ use core::{fmt, i64}; #[cfg(any(feature = "std", test))] use std::error::Error; +#[cfg(feature = "rkyv")] +use rkyv::{Archive, Deserialize, Serialize}; + /// The number of nanoseconds in a microsecond. const NANOS_PER_MICRO: i32 = 1000; /// The number of nanoseconds in a millisecond. @@ -48,6 +51,7 @@ macro_rules! try_opt { /// /// This also allows for the negative duration; see individual methods for details. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] +#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))] pub struct Duration { secs: i64, nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC diff --git a/src/weekday.rs b/src/weekday.rs index 3b9d839f..58f61f2f 100644 --- a/src/weekday.rs +++ b/src/weekday.rs @@ -1,5 +1,8 @@ use core::fmt; +#[cfg(feature = "rkyv")] +use rkyv::{Archive, Deserialize, Serialize}; + /// The day of week. /// /// The order of the days of week depends on the context. @@ -7,6 +10,7 @@ use core::fmt; /// One should prefer `*_from_monday` or `*_from_sunday` methods to get the correct result. #[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)] #[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))] +#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))] pub enum Weekday { /// Monday. Mon = 0,