Skip to content

Commit e920210

Browse files
dovahcrowdjc
authored andcommitted
add missing rkyv derives
1 parent 5bf8016 commit e920210

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

src/datetime/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ use crate::oldtime::Duration as OldDuration;
3232
use crate::Date;
3333
use crate::{Datelike, Timelike, Weekday};
3434

35+
#[cfg(feature = "rkyv")]
36+
use rkyv::{Archive, Deserialize, Serialize};
37+
3538
#[cfg(feature = "rustc-serialize")]
3639
pub(super) mod rustc_serialize;
3740

@@ -79,6 +82,7 @@ pub enum SecondsFormat {
7982
/// the general-purpose constructors are all via the methods on the
8083
/// [`TimeZone`](./offset/trait.TimeZone.html) implementations.
8184
#[derive(Clone)]
85+
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
8286
pub struct DateTime<Tz: TimeZone> {
8387
datetime: NaiveDateTime,
8488
offset: Tz::Offset,

src/month.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use core::fmt;
22

3+
#[cfg(feature = "rkyv")]
4+
use rkyv::{Archive, Deserialize, Serialize};
5+
36
/// The month of the year.
47
///
58
/// This enum is just a convenience implementation.
@@ -26,6 +29,7 @@ use core::fmt;
2629
// Actual implementation is zero-indexed, API intended as 1-indexed for more intuitive behavior.
2730
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
2831
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
32+
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
2933
pub enum Month {
3034
/// January
3135
January = 0,

src/naive/isoweek.rs

+4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ use core::fmt;
77

88
use super::internals::{DateImpl, Of, YearFlags};
99

10+
#[cfg(feature = "rkyv")]
11+
use rkyv::{Archive, Deserialize, Serialize};
12+
1013
/// ISO 8601 week.
1114
///
1215
/// This type, combined with [`Weekday`](../enum.Weekday.html),
1316
/// constitutes the ISO 8601 [week date](./struct.NaiveDate.html#week-date).
1417
/// One can retrieve this type from the existing [`Datelike`](../trait.Datelike.html) types
1518
/// via the [`Datelike::iso_week`](../trait.Datelike.html#tymethod.iso_week) method.
1619
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone)]
20+
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
1721
pub struct IsoWeek {
1822
// note that this allows for larger year range than `NaiveDate`.
1923
// this is crucial because we have an edge case for the first and last week supported,

src/oldtime.rs

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ use core::{fmt, i64};
1616
#[cfg(any(feature = "std", test))]
1717
use std::error::Error;
1818

19+
#[cfg(feature = "rkyv")]
20+
use rkyv::{Archive, Deserialize, Serialize};
21+
1922
/// The number of nanoseconds in a microsecond.
2023
const NANOS_PER_MICRO: i32 = 1000;
2124
/// The number of nanoseconds in a millisecond.
@@ -48,6 +51,7 @@ macro_rules! try_opt {
4851
///
4952
/// This also allows for the negative duration; see individual methods for details.
5053
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
54+
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
5155
pub struct Duration {
5256
secs: i64,
5357
nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC

src/weekday.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
use core::fmt;
22

3+
#[cfg(feature = "rkyv")]
4+
use rkyv::{Archive, Deserialize, Serialize};
5+
36
/// The day of week.
47
///
58
/// The order of the days of week depends on the context.
69
/// (This is why this type does *not* implement `PartialOrd` or `Ord` traits.)
710
/// One should prefer `*_from_monday` or `*_from_sunday` methods to get the correct result.
811
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
912
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
13+
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
1014
pub enum Weekday {
1115
/// Monday.
1216
Mon = 0,

0 commit comments

Comments
 (0)