Skip to content

Commit

Permalink
Use rkyv instead of dep:rkyv.
Browse files Browse the repository at this point in the history
So we don't need rust 1.60 msrvp.

Signed-off-by: Gerd Zellweger <[email protected]>
  • Loading branch information
gz committed Dec 16, 2023
1 parent 68035dd commit 254b11a
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 86 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ std = ["alloc"]
clock = ["std", "winapi", "iana-time-zone", "android-tzdata"]
wasmbind = ["wasm-bindgen", "js-sys"]
unstable-locales = ["pure-rust-locales"]
rkyv = ["rkyv-32"]
# Note that rkyv-16, rkyv-32, and rkyv-64 are mutually exclusive.
rkyv = ["rkyv-32"]
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"]
# Features for internal use only:
__internal_bench = []
__internal_rkyv = ["dep:rkyv"]
__internal_rkyv = ["rkyv"]

[dependencies]
serde = { version = "1.0.99", default-features = false, optional = true }
Expand Down
5 changes: 1 addition & 4 deletions src/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,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 = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
pub struct DateTime<Tz: TimeZone> {
datetime: NaiveDateTime,
offset: Tz::Offset,
Expand Down
10 changes: 2 additions & 8 deletions src/month.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,12 @@ use crate::OutOfRange;
/// Can be Serialized/Deserialized with serde
// Actual implementation is zero-indexed, API intended as 1-indexed for more intuitive behavior.
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq, PartialOrd))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq, PartialOrd)))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum Month {
/// January
Expand Down
10 changes: 2 additions & 8 deletions src/naive/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,12 @@ impl Days {
///
/// [proleptic Gregorian date]: crate::NaiveDate#calendar-date
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq, PartialOrd))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq, PartialOrd)))]
pub struct NaiveDate {
ymdf: DateImpl, // (year << 13) | of
}
Expand Down
10 changes: 2 additions & 8 deletions src/naive/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,12 @@ pub const MAX_DATETIME: NaiveDateTime = NaiveDateTime::MAX;
/// assert_eq!(dt.num_seconds_from_midnight(), 33011);
/// ```
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq, PartialOrd))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq, PartialOrd)))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct NaiveDateTime {
date: NaiveDate,
Expand Down
10 changes: 2 additions & 8 deletions src/naive/isoweek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ use rkyv::{Archive, Deserialize, Serialize};
/// 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, Hash)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq, PartialOrd))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq, PartialOrd)))]
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,
Expand Down
10 changes: 2 additions & 8 deletions src/naive/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,12 @@ mod tests;
/// Since Chrono alone cannot determine any existence of leap seconds,
/// **there is absolutely no guarantee that the leap second read has actually happened**.
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq, PartialOrd))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq, PartialOrd)))]
pub struct NaiveTime {
secs: u32,
frac: u32,
Expand Down
10 changes: 2 additions & 8 deletions src/offset/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ use crate::{NaiveDateTime, ParseError};
/// `DateTime<FixedOffset>` instances. See the [`east_opt`](#method.east_opt) and
/// [`west_opt`](#method.west_opt) methods for examples.
#[derive(PartialEq, Eq, Hash, Copy, Clone)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, Hash, Debug))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq)))]
pub struct FixedOffset {
local_minus_utc: i32,
}
Expand Down
10 changes: 2 additions & 8 deletions src/offset/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,8 @@ mod tz_info;
/// assert!(dt1 >= dt2);
/// ```
#[derive(Copy, Clone, Debug)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, Debug))
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(feature = "__internal_rkyv", archive_attr(derive(Clone, Copy, Debug)))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Local;

Expand Down
10 changes: 2 additions & 8 deletions src/offset/utc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,12 @@ use crate::DateTime;
/// assert_eq!(Utc.with_ymd_and_hms(1970, 1, 1, 0, 1, 1).unwrap(), dt);
/// ```
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq)))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Utc;

Expand Down
10 changes: 2 additions & 8 deletions src/time_delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,12 @@ macro_rules! try_opt {
///
/// This also allows for the negative duration; see individual methods for details.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq, PartialOrd))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq, PartialOrd)))]
pub struct TimeDelta {
secs: i64,
nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC
Expand Down
10 changes: 2 additions & 8 deletions src/weekday.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ use crate::OutOfRange;
/// assert_eq!(sunday.pred(), Weekday::Sat);
/// ```
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
#[cfg_attr(
feature = "__internal_rkyv",
derive(Archive, Deserialize, Serialize)
)]
#[cfg_attr(feature = "__internal_rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "__internal_rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash))
)]
#[cfg_attr(
feature = "__internal_rkyv",
archive(compare(PartialEq))
)]
#[cfg_attr(feature = "__internal_rkyv", archive(compare(PartialEq)))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum Weekday {
/// Monday.
Expand Down

0 comments on commit 254b11a

Please sign in to comment.