mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-28 13:31:35 +00:00
add missing rkyv derives
This commit is contained in:
parent
5bf8016068
commit
e920210e2f
@ -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<Tz: TimeZone> {
|
||||
datetime: NaiveDateTime,
|
||||
offset: Tz::Offset,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user