1use crate::constants as c;
19
20macro_rules! define_bounds {
27 ($(
28 $(#[$attr:meta])*
29 (
30 $name:ident,
32 $ty:ident,
36 $what:expr,
39 $min:expr,
41 $max:expr $(,)?
43 )
44 ),* $(,)?) => {
45 $(
46 $(#[$attr])*
47 #[allow(missing_debug_implementations)]
48 #[allow(missing_docs)]
49 #[derive(Eq, PartialEq)]
50 pub struct $name(());
51
52 impl Bounds for $name {
53 const WHAT: &'static str = $what;
54 const MIN: Self::Primitive = $min;
55 const MAX: Self::Primitive = $max;
56 type Primitive = $ty;
57 type Error = BoundsError;
58
59 #[cold]
60 #[inline(never)]
61 fn error() -> BoundsError {
62 Self::error()
63 }
64 }
65
66 #[allow(dead_code)]
67 #[allow(missing_docs)]
68 impl $name {
69 pub const MIN: $ty = <$name as Bounds>::MIN;
70 pub const MAX: $ty = <$name as Bounds>::MAX;
71 pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
72
73 #[cold]
74 pub const fn error() -> BoundsError {
75 BoundsError {
76 kind: BoundsErrorKind::$name(RawBoundsError::new()),
77 }
78 }
79
80 #[inline(always)]
81 pub fn check(n: impl Into<i64>) -> Result<$ty, BoundsError> {
82 <$name as Bounds>::check(n)
83 }
84
85 #[inline(always)]
86 pub const fn checkc(n: i64) -> Result<$ty, BoundsError> {
87 match self::const_check::$ty(n) {
88 Ok(n) => Ok(n),
89 Err(err) => Err(BoundsError {
90 kind: BoundsErrorKind::$name(err),
91 }),
92 }
93 }
94
95 #[inline(always)]
96 pub const fn checked_add(n1: $ty, n2: $ty) -> Result<$ty, BoundsError> {
97 match self::const_checked_add::$ty(n1, n2) {
98 Ok(n) => Ok(n),
99 Err(err) => Err(BoundsError {
100 kind: BoundsErrorKind::$name(err),
101 }),
102 }
103 }
104
105 #[inline(always)]
106 pub fn checked_mul(n1: $ty, n2: $ty) -> Result<$ty, BoundsError> {
107 <$name as Bounds>::checked_mul(n1, n2)
108 }
109
110 #[cfg(test)]
111 pub(crate) fn arbitrary(g: &mut quickcheck::Gen) -> $ty {
112 use quickcheck::Arbitrary;
113
114 let mut n: $ty = <$ty>::arbitrary(g);
115 n = n.wrapping_rem_euclid(Self::LEN as $ty);
116 n += Self::MIN;
117 n
118 }
119 }
120 )*
121
122 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
124 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
125 enum BoundsErrorKind {
126 $($name(RawBoundsError<$name>),)*
127 }
128
129 impl core::fmt::Display for BoundsErrorKind {
130 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
131 match *self {
132 $(BoundsErrorKind::$name(ref err) => err.fmt(f),)*
133 }
134 }
135 }
136 }
137}
138
139#[doc = r" The supported range of nanoseconds in a single civil day."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct CivilDayNanosecond(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for CivilDayNanosecond {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for CivilDayNanosecond { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for CivilDayNanosecond {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for CivilDayNanosecond {
const WHAT: &'static str = "nanoseconds (in one civil day)";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = c::NANOS_PER_CIVIL_DAY - 1;
type Primitive = i64;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl CivilDayNanosecond {
pub const MIN: i64 = <CivilDayNanosecond as Bounds>::MIN;
pub const MAX: i64 = <CivilDayNanosecond as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::CivilDayNanosecond(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i64, BoundsError> {
<CivilDayNanosecond as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i64, BoundsError> {
match self::const_check::i64(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::CivilDayNanosecond(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i64, n2: i64) -> Result<i64, BoundsError> {
match self::const_checked_add::i64(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::CivilDayNanosecond(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i64, n2: i64) -> Result<i64, BoundsError> {
<CivilDayNanosecond as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of seconds in a single civil day."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct CivilDaySecond(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for CivilDaySecond {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for CivilDaySecond { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for CivilDaySecond {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for CivilDaySecond {
const WHAT: &'static str = "seconds (in one civil day)";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = c::SECS_PER_CIVIL_DAY_32 - 1;
type Primitive = i32;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl CivilDaySecond {
pub const MIN: i32 = <CivilDaySecond as Bounds>::MIN;
pub const MAX: i32 = <CivilDaySecond as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::CivilDaySecond(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i32, BoundsError> {
<CivilDaySecond as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i32, BoundsError> {
match self::const_check::i32(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::CivilDaySecond(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i32, n2: i32) -> Result<i32, BoundsError> {
match self::const_checked_add::i32(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::CivilDaySecond(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i32, n2: i32) -> Result<i32, BoundsError> {
<CivilDaySecond as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r#" The supported range of "day of month.""#]
#[doc = r""]
#[doc = r" While the maximum value is 31, the actual maximum depends on the"]
#[doc =
r" specific month. The smallest possible maximum for any month is `28`"]
#[doc = r" for February."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Day(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Day {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Day { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Day {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Day {
const WHAT: &'static str = "day";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = 31;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Day {
pub const MIN: i8 = <Day as Bounds>::MIN;
pub const MAX: i8 = <Day as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::Day(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<Day as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) => Err(BoundsError { kind: BoundsErrorKind::Day(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) => Err(BoundsError { kind: BoundsErrorKind::Day(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<Day as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r#" The supported range of "day of year.""#]
#[doc = r""]
#[doc = r" This includes Feb 29 in leap years. For non-leap years, `366` is"]
#[doc = r" invalid. The value `1` always corresponds to Jan 1."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct DayOfYear(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for DayOfYear {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for DayOfYear { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for DayOfYear {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for DayOfYear {
const WHAT: &'static str = "day-of-year";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = 366;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl DayOfYear {
pub const MIN: i16 = <DayOfYear as Bounds>::MIN;
pub const MAX: i16 = <DayOfYear as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::DayOfYear(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<DayOfYear as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::DayOfYear(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::DayOfYear(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<DayOfYear as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r#" The supported range of "day of year," but never including Feb 29."#]
#[doc = r""]
#[doc =
r" This means that the valid range for all years is `1..=365`. And there"]
#[doc = r" is no way to refer to Feb 29 in this scheme."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct DayOfYearNoLeap(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for DayOfYearNoLeap {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for DayOfYearNoLeap { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for DayOfYearNoLeap {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for DayOfYearNoLeap {
const WHAT: &'static str = "day-of-year (skipping Feb 29)";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = 365;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl DayOfYearNoLeap {
pub const MIN: i16 = <DayOfYearNoLeap as Bounds>::MIN;
pub const MAX: i16 = <DayOfYearNoLeap as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::DayOfYearNoLeap(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<DayOfYearNoLeap as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::DayOfYearNoLeap(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::DayOfYearNoLeap(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<DayOfYearNoLeap as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r" The range of seconds for the possible differences between any two pairs"]
#[doc = r" of `(timestamp, offset)`."]
#[doc = r""]
#[doc =
r" All of our span types (except for years and months, since they have"]
#[doc =
r" variable length even in civil datetimes) are defined in terms of this"]
#[doc =
r" constant. The way it's defined is a little odd, so let's break it down."]
#[doc = r""]
#[doc =
r" Firstly, a span of seconds should be able to represent at least the"]
#[doc = r" complete span supported by `Timestamp`. Thus, it's based off of"]
#[doc =
r" `UnixSeconds::LEN`. That is, a span should be able to represent the"]
#[doc = r" value `UnixSeconds::MAX - UnixSeconds::MIN`."]
#[doc = r""]
#[doc = r" Secondly, a span should also be able to account for any amount of"]
#[doc = r" possible time that a time zone offset might add or subtract to an"]
#[doc =
r" `Timestamp`. This also means it can account for any difference between"]
#[doc = r" two `civil::DateTime` values."]
#[doc = r""]
#[doc = r" Thirdly, we would like our span to be divisible by"]
#[doc =
r" `SECONDS_PER_CIVIL_DAY`. This isn't strictly required, but it makes"]
#[doc =
r" defining boundaries a little smoother. If it weren't divisible, then the"]
#[doc = r" lower bounds on some types would need to be adjusted by one."]
#[doc = r""]
#[doc = r" Note that neither the existence of this constant nor defining our"]
#[doc =
r" spans based on it impacts the correctness of doing arithmetic on zoned"]
#[doc =
r#" instants. Arithmetic on zoned instants still uses "civil" spans, but the"#]
#[doc =
r" length of time for some units (like a day) might vary. The arithmetic"]
#[doc =
r" for zoned instants accounts for this explicitly. But it still must obey"]
#[doc = r" the limits set here."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct DeltaSeconds(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for DeltaSeconds {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for DeltaSeconds { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for DeltaSeconds {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for DeltaSeconds {
const WHAT: &'static str = "seconds";
const MIN: Self::Primitive = -Self::MAX;
const MAX: Self::Primitive =
next_multiple_of(UnixEpochSeconds::LEN as i64 +
OffsetTotalSeconds::MAX as i64 + c::SECS_PER_CIVIL_DAY,
c::SECS_PER_CIVIL_DAY);
type Primitive = i64;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl DeltaSeconds {
pub const MIN: i64 = <DeltaSeconds as Bounds>::MIN;
pub const MAX: i64 = <DeltaSeconds as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::DeltaSeconds(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i64, BoundsError> {
<DeltaSeconds as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i64, BoundsError> {
match self::const_check::i64(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::DeltaSeconds(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i64, n2: i64) -> Result<i64, BoundsError> {
match self::const_checked_add::i64(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::DeltaSeconds(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i64, n2: i64) -> Result<i64, BoundsError> {
<DeltaSeconds as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The range of hours supported."]
#[doc = r""]
#[doc =
r#" Jiff always uses the "24 hour clock" where midnight is hour `0` and"#]
#[doc =
r" 11pm is `23`. The alternative spelling of midnight, `24:00`, is not"]
#[doc = r" supported."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Hour(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Hour {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Hour { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Hour {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Hour {
const WHAT: &'static str = "hour";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = 23;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Hour {
pub const MIN: i8 = <Hour as Bounds>::MIN;
pub const MAX: i8 = <Hour as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::Hour(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<Hour as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) => Err(BoundsError { kind: BoundsErrorKind::Hour(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) => Err(BoundsError { kind: BoundsErrorKind::Hour(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<Hour as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r" The supported range of week numbers in the ISO 8601 week calendar."]
#[doc = r""]
#[doc = r" ISO 8601 leap years have exactly 53 weeks. Non-leap years have 52"]
#[doc = r" weeks."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct ISOWeek(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for ISOWeek {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for ISOWeek { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for ISOWeek {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for ISOWeek {
const WHAT: &'static str = "iso-week";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = 53;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl ISOWeek {
pub const MIN: i8 = <ISOWeek as Bounds>::MIN;
pub const MAX: i8 = <ISOWeek as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::ISOWeek(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<ISOWeek as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::ISOWeek(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::ISOWeek(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<ISOWeek as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r" The supported range of year numbers in the ISO 8601 week calendar."]
#[doc = r""]
#[doc = r" This matches the supported range of Gregorian year numbers."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct ISOYear(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for ISOYear {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for ISOYear { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for ISOYear {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for ISOYear {
const WHAT: &'static str = "iso-year";
const MIN: Self::Primitive = Year::MIN;
const MAX: Self::Primitive = Year::MAX;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl ISOYear {
pub const MIN: i16 = <ISOYear as Bounds>::MIN;
pub const MAX: i16 = <ISOYear as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::ISOYear(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<ISOYear as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::ISOYear(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::ISOYear(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<ISOYear as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of microsecond values."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Microsecond(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Microsecond {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Microsecond { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Microsecond {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Microsecond {
const WHAT: &'static str = "microsecond";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = 999;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Microsecond {
pub const MIN: i16 = <Microsecond as Bounds>::MIN;
pub const MAX: i16 = <Microsecond as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::Microsecond(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<Microsecond as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Microsecond(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Microsecond(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<Microsecond as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of millisecond values."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Millisecond(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Millisecond {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Millisecond { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Millisecond {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Millisecond {
const WHAT: &'static str = "millisecond";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = 999;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Millisecond {
pub const MIN: i16 = <Millisecond as Bounds>::MIN;
pub const MAX: i16 = <Millisecond as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::Millisecond(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<Millisecond as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Millisecond(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Millisecond(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<Millisecond as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of minute values."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Minute(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Minute {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Minute { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Minute {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Minute {
const WHAT: &'static str = "minute";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = 59;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Minute {
pub const MIN: i8 = <Minute as Bounds>::MIN;
pub const MAX: i8 = <Minute as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::Minute(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<Minute as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Minute(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Minute(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<Minute as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of month values."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Month(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Month {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Month { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Month {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Month {
const WHAT: &'static str = "month";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = 12;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Month {
pub const MIN: i8 = <Month as Bounds>::MIN;
pub const MAX: i8 = <Month as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::Month(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<Month as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Month(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Month(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<Month as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of nanosecond values."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Nanosecond(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Nanosecond {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Nanosecond { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Nanosecond {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Nanosecond {
const WHAT: &'static str = "nanosecond";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = 999;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Nanosecond {
pub const MIN: i16 = <Nanosecond as Bounds>::MIN;
pub const MAX: i16 = <Nanosecond as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::Nanosecond(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<Nanosecond as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Nanosecond(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Nanosecond(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<Nanosecond as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r#" The supported range of values for getting the "nth weekday" from a"#]
#[doc = r" date."]
#[doc = r""]
#[doc = r" Note that `0` is also invalid, but this is not expressed by"]
#[doc = r" this single contiguous range."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct NthWeekday(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for NthWeekday {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for NthWeekday { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for NthWeekday {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for NthWeekday {
const WHAT: &'static str = "nth weekday";
const MIN: Self::Primitive = -Self::MAX;
const MAX: Self::Primitive =
(DeltaSeconds::MAX / c::SECS_PER_CIVIL_WEEK) as i32;
type Primitive = i32;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl NthWeekday {
pub const MIN: i32 = <NthWeekday as Bounds>::MIN;
pub const MAX: i32 = <NthWeekday as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::NthWeekday(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i32, BoundsError> {
<NthWeekday as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i32, BoundsError> {
match self::const_check::i32(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::NthWeekday(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i32, n2: i32) -> Result<i32, BoundsError> {
match self::const_checked_add::i32(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::NthWeekday(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i32, n2: i32) -> Result<i32, BoundsError> {
<NthWeekday as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r#" The supported range of values for getting the "nth weekday of a month""#]
#[doc = r" from a particular date."]
#[doc = r""]
#[doc = r" Note that `0` is also invalid, but this is not expressed by"]
#[doc =
r" this single contiguous range. Note also that `5` or `-5` can be invalid"]
#[doc =
r" if the provided month does not contain a 5th instance of the weekday"]
#[doc = r" provided by the caller."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct NthWeekdayOfMonth(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for NthWeekdayOfMonth {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for NthWeekdayOfMonth { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for NthWeekdayOfMonth {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for NthWeekdayOfMonth {
const WHAT: &'static str = "nth weekday of month";
const MIN: Self::Primitive = -5;
const MAX: Self::Primitive = 5;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl NthWeekdayOfMonth {
pub const MIN: i8 = <NthWeekdayOfMonth as Bounds>::MIN;
pub const MAX: i8 = <NthWeekdayOfMonth as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::NthWeekdayOfMonth(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<NthWeekdayOfMonth as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::NthWeekdayOfMonth(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::NthWeekdayOfMonth(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<NthWeekdayOfMonth as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The number of hours allowed in a time zone offset."]
#[doc = r""]
#[doc = r" This number was somewhat arbitrarily chosen. In part because it's"]
#[doc =
r" bigger than any current offset in actual use by a wide margin, and in"]
#[doc =
r" part because POSIX `TZ` strings require the ability to store offsets in"]
#[doc =
r" the range `-24:59:59..=25:59:59`. Note though that we make the range a"]
#[doc =
r" little bigger with `-25:59:59..=25:59:59` so that negating an offset"]
#[doc = r" always produces a valid offset."]
#[doc = r""]
#[doc =
r" Note that RFC 8536 actually allows offsets to be much bigger, namely,"]
#[doc =
r" in the range `(-2^31, 2^31)`, where both ends are _exclusive_ (`-2^31`"]
#[doc = r" is explicitly disallowed, and `2^31` overflows a signed 32-bit"]
#[doc = r" integer). But RFC 8536 does say that it *should* be in the range"]
#[doc =
r" `[-89999, 93599]`, which matches POSIX. In order to keep our offset"]
#[doc = r" small, we stick roughly to what POSIX requires."]
#[doc = r""]
#[doc =
r" Note that we support a slightly bigger range of offsets than Temporal."]
#[doc = r" Temporal seems to support only up to 23 hours, but we go up to 25"]
#[doc =
r" hours. This is done to support POSIX time zone strings, which also"]
#[doc = r" require 25 hours (plus the maximal minute/second components)."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct OffsetHours(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for OffsetHours {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for OffsetHours { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for OffsetHours {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for OffsetHours {
const WHAT: &'static str = "time zone offset hours";
const MIN: Self::Primitive = -25;
const MAX: Self::Primitive = 25;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl OffsetHours {
pub const MIN: i8 = <OffsetHours as Bounds>::MIN;
pub const MAX: i8 = <OffsetHours as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::OffsetHours(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<OffsetHours as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::OffsetHours(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::OffsetHours(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<OffsetHours as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r#" The supported range of "minute" component of a time zone offset."#]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct OffsetMinutes(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for OffsetMinutes {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for OffsetMinutes { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for OffsetMinutes {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for OffsetMinutes {
const WHAT: &'static str = "time zone offset minutes";
const MIN: Self::Primitive = -59;
const MAX: Self::Primitive = 59;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl OffsetMinutes {
pub const MIN: i8 = <OffsetMinutes as Bounds>::MIN;
pub const MAX: i8 = <OffsetMinutes as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::OffsetMinutes(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<OffsetMinutes as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::OffsetMinutes(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::OffsetMinutes(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<OffsetMinutes as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r#" The supported range of "second" component of a time zone offset."#]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct OffsetSeconds(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for OffsetSeconds {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for OffsetSeconds { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for OffsetSeconds {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for OffsetSeconds {
const WHAT: &'static str = "time zone offset seconds";
const MIN: Self::Primitive = -59;
const MAX: Self::Primitive = 59;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl OffsetSeconds {
pub const MIN: i8 = <OffsetSeconds as Bounds>::MIN;
pub const MAX: i8 = <OffsetSeconds as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::OffsetSeconds(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<OffsetSeconds as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::OffsetSeconds(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::OffsetSeconds(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<OffsetSeconds as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of time zone offsets, expressed in units of"]
#[doc = r" seconds."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct OffsetTotalSeconds(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for OffsetTotalSeconds {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for OffsetTotalSeconds { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for OffsetTotalSeconds {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for OffsetTotalSeconds {
const WHAT: &'static str = "time zone offset total seconds";
const MIN: Self::Primitive = -Self::MAX;
const MAX: Self::Primitive =
(OffsetHours::MAX as i32 * c::SECS_PER_HOUR_32) +
(OffsetMinutes::MAX as i32 * c::MINS_PER_HOUR_32) +
OffsetSeconds::MAX as i32;
type Primitive = i32;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl OffsetTotalSeconds {
pub const MIN: i32 = <OffsetTotalSeconds as Bounds>::MIN;
pub const MAX: i32 = <OffsetTotalSeconds as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::OffsetTotalSeconds(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i32, BoundsError> {
<OffsetTotalSeconds as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i32, BoundsError> {
match self::const_check::i32(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::OffsetTotalSeconds(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i32, n2: i32) -> Result<i32, BoundsError> {
match self::const_checked_add::i32(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::OffsetTotalSeconds(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i32, n2: i32) -> Result<i32, BoundsError> {
<OffsetTotalSeconds as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of second values."]
#[doc = r""]
#[doc = r" Note that Jiff does not support leap seconds. So a value of `60`"]
#[doc = r" is never valid. (Except when parsing. In which case, Jiff will"]
#[doc = r" automatically clamp the value `60` to `59`.)"]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Second(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Second {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Second { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Second {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Second {
const WHAT: &'static str = "second";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = 59;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Second {
pub const MIN: i8 = <Second as Bounds>::MIN;
pub const MAX: i8 = <Second as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::Second(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<Second as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Second(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::Second(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<Second as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of fractional seconds, expressed in units of"]
#[doc = r" nanoseconds."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct SubsecNanosecond(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for SubsecNanosecond {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for SubsecNanosecond { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for SubsecNanosecond {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for SubsecNanosecond {
const WHAT: &'static str = "subsecond nanosecond";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = c::NANOS_PER_SEC_32 - 1;
type Primitive = i32;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl SubsecNanosecond {
pub const MIN: i32 = <SubsecNanosecond as Bounds>::MIN;
pub const MAX: i32 = <SubsecNanosecond as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::SubsecNanosecond(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i32, BoundsError> {
<SubsecNanosecond as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i32, BoundsError> {
match self::const_check::i32(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::SubsecNanosecond(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i32, n2: i32) -> Result<i32, BoundsError> {
match self::const_checked_add::i32(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::SubsecNanosecond(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i32, n2: i32) -> Result<i32, BoundsError> {
<SubsecNanosecond as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of a timestamp's subsecond component."]
#[doc = r""]
#[doc =
r" This is different from `SubsecNanosecond`, which applies to civil time"]
#[doc = r" within a single day, in that it can be negative. For example, the"]
#[doc =
r" timestamp `-0s 123ms` refers to 123 milliseconds before the Unix epoch."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct SignedSubsecNanosecond(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for SignedSubsecNanosecond {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for SignedSubsecNanosecond { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for SignedSubsecNanosecond {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for SignedSubsecNanosecond {
const WHAT: &'static str = "subsecond nanosecond";
const MIN: Self::Primitive = -SubsecNanosecond::MAX;
const MAX: Self::Primitive = SubsecNanosecond::MAX;
type Primitive = i32;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl SignedSubsecNanosecond {
pub const MIN: i32 = <SignedSubsecNanosecond as Bounds>::MIN;
pub const MAX: i32 = <SignedSubsecNanosecond as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::SignedSubsecNanosecond(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i32, BoundsError> {
<SignedSubsecNanosecond as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i32, BoundsError> {
match self::const_check::i32(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::SignedSubsecNanosecond(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i32, n2: i32) -> Result<i32, BoundsError> {
match self::const_checked_add::i32(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::SignedSubsecNanosecond(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i32, n2: i32) -> Result<i32, BoundsError> {
<SignedSubsecNanosecond as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r" An error that occurs when doing arithmetic on a timestamp overflows"]
#[doc = r" the `i32` representation of a nanosecond."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct TimestampArithmeticNanosecond(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for TimestampArithmeticNanosecond {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for TimestampArithmeticNanosecond { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for TimestampArithmeticNanosecond {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for TimestampArithmeticNanosecond {
const WHAT: &'static str = "nanosecond";
const MIN: Self::Primitive = i32::MIN;
const MAX: Self::Primitive = i32::MAX;
type Primitive = i32;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl TimestampArithmeticNanosecond {
pub const MIN: i32 = <TimestampArithmeticNanosecond as Bounds>::MIN;
pub const MAX: i32 = <TimestampArithmeticNanosecond as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::TimestampArithmeticNanosecond(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i32, BoundsError> {
<TimestampArithmeticNanosecond as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i32, BoundsError> {
match self::const_check::i32(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::TimestampArithmeticNanosecond(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i32, n2: i32) -> Result<i32, BoundsError> {
match self::const_checked_add::i32(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::TimestampArithmeticNanosecond(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i32, n2: i32) -> Result<i32, BoundsError> {
<TimestampArithmeticNanosecond as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of days from the Unix epoch for the Gregorian"]
#[doc = r" calendar."]
#[doc = r""]
#[doc =
r" The range supported is based on the range of Unix timestamps that we"]
#[doc = r" support."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct UnixEpochDays(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for UnixEpochDays {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for UnixEpochDays { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for UnixEpochDays {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for UnixEpochDays {
const WHAT: &'static str = "Unix epoch days";
const MIN: Self::Primitive =
(UnixEpochSeconds::MIN +
OffsetTotalSeconds::MIN as
i64).div_euclid(c::SECS_PER_CIVIL_DAY) as i32;
const MAX: Self::Primitive =
(UnixEpochSeconds::MAX +
OffsetTotalSeconds::MAX as
i64).div_euclid(c::SECS_PER_CIVIL_DAY) as i32;
type Primitive = i32;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl UnixEpochDays {
pub const MIN: i32 = <UnixEpochDays as Bounds>::MIN;
pub const MAX: i32 = <UnixEpochDays as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::UnixEpochDays(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i32, BoundsError> {
<UnixEpochDays as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i32, BoundsError> {
match self::const_check::i32(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::UnixEpochDays(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i32, n2: i32) -> Result<i32, BoundsError> {
match self::const_checked_add::i32(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::UnixEpochDays(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i32, n2: i32) -> Result<i32, BoundsError> {
<UnixEpochDays as Bounds>::checked_mul(n1, n2)
}
}
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct UnixEpochMilliseconds(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for UnixEpochMilliseconds {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for UnixEpochMilliseconds { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for UnixEpochMilliseconds {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for UnixEpochMilliseconds {
const WHAT: &'static str = "Unix timestamp milliseconds";
const MIN: Self::Primitive = UnixEpochSeconds::MIN * c::MILLIS_PER_SEC;
const MAX: Self::Primitive =
(UnixEpochSeconds::MAX + 1) * c::MILLIS_PER_SEC - 1;
type Primitive = i64;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl UnixEpochMilliseconds {
pub const MIN: i64 = <UnixEpochMilliseconds as Bounds>::MIN;
pub const MAX: i64 = <UnixEpochMilliseconds as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::UnixEpochMilliseconds(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i64, BoundsError> {
<UnixEpochMilliseconds as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i64, BoundsError> {
match self::const_check::i64(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::UnixEpochMilliseconds(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i64, n2: i64) -> Result<i64, BoundsError> {
match self::const_checked_add::i64(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::UnixEpochMilliseconds(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i64, n2: i64) -> Result<i64, BoundsError> {
<UnixEpochMilliseconds as Bounds>::checked_mul(n1, n2)
}
}
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct UnixEpochMicroseconds(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for UnixEpochMicroseconds {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for UnixEpochMicroseconds { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for UnixEpochMicroseconds {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for UnixEpochMicroseconds {
const WHAT: &'static str = "Unix timestamp microseconds";
const MIN: Self::Primitive =
UnixEpochMilliseconds::MIN * c::MICROS_PER_MILLI;
const MAX: Self::Primitive =
(UnixEpochMilliseconds::MAX + 1) * c::MICROS_PER_MILLI - 1;
type Primitive = i64;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl UnixEpochMicroseconds {
pub const MIN: i64 = <UnixEpochMicroseconds as Bounds>::MIN;
pub const MAX: i64 = <UnixEpochMicroseconds as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::UnixEpochMicroseconds(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i64, BoundsError> {
<UnixEpochMicroseconds as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i64, BoundsError> {
match self::const_check::i64(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::UnixEpochMicroseconds(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i64, n2: i64) -> Result<i64, BoundsError> {
match self::const_checked_add::i64(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::UnixEpochMicroseconds(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i64, n2: i64) -> Result<i64, BoundsError> {
<UnixEpochMicroseconds as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The supported range of seconds for the difference between any two"]
#[doc = r" values of `UnixEpochDays`."]
#[doc = r""]
#[doc = r" This range should correspond to the first second of `Year::MIN`"]
#[doc =
r" (with a minimal offset) up through (and including) the last second"]
#[doc =
r" of `Year::MAX` (with a maximal offset). Actually computing that is"]
#[doc = r" non-trivial, however, it can be computed easily enough using Unix"]
#[doc = r" programs like `date`:"]
#[doc = r""]
#[doc = r" ```text"]
#[doc = r" $ TZ=0 date -d 'Mon Jan 1 12:00:00 AM -9999' +'%s'"]
#[doc = r" date: invalid date ‘Mon Jan 1 12:00:00 AM -9999’"]
#[doc = r" $ TZ=0 date -d 'Fri Dec 31 23:59:59 9999' +'%s'"]
#[doc = r" 253402300799"]
#[doc = r" ```"]
#[doc = r""]
#[doc =
r" Well, almost easily enough. `date` apparently doesn't support negative"]
#[doc = r" years. But it does support negative timestamps:"]
#[doc = r""]
#[doc = r" ```text"]
#[doc = r" $ TZ=0 date -d '@-377705116800'"]
#[doc = r" Mon Jan 1 12:00:00 AM -9999"]
#[doc = r" $ TZ=0 date -d '@253402300799'"]
#[doc = r" Fri Dec 31 11:59:59 PM 9999"]
#[doc = r" ```"]
#[doc = r""]
#[doc =
r" With that said, we actually end up restricting the range a bit more"]
#[doc =
r" than what's above. Namely, what's above is what we support for civil"]
#[doc = r" datetimes. Because of time zones, we need to choose whether all"]
#[doc =
r" `Timestamp` values can be infallibly converted to `civil::DateTime`"]
#[doc = r" values, or whether all `civil::DateTime` values can be infallibly"]
#[doc =
r" converted to `Timestamp` values. Jiff choses the former because getting"]
#[doc =
r" a civil datetime is important for formatting. If Jiff didn't choose the"]
#[doc =
r" former, there would be some timestamps that could not be formatted."]
#[doc = r" Thus, we make room by shrinking the range of allowed instants by"]
#[doc = r" precisely the maximum supported time zone offset."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct UnixEpochSeconds(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for UnixEpochSeconds {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for UnixEpochSeconds { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for UnixEpochSeconds {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for UnixEpochSeconds {
const WHAT: &'static str = "Unix timestamp seconds";
const MIN: Self::Primitive =
-377705116800 - OffsetTotalSeconds::MIN as i64;
const MAX: Self::Primitive =
253402300799 - OffsetTotalSeconds::MAX as i64;
type Primitive = i64;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl UnixEpochSeconds {
pub const MIN: i64 = <UnixEpochSeconds as Bounds>::MIN;
pub const MAX: i64 = <UnixEpochSeconds as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::UnixEpochSeconds(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i64, BoundsError> {
<UnixEpochSeconds as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i64, BoundsError> {
match self::const_check::i64(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::UnixEpochSeconds(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i64, n2: i64) -> Result<i64, BoundsError> {
match self::const_checked_add::i64(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::UnixEpochSeconds(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i64, n2: i64) -> Result<i64, BoundsError> {
<UnixEpochSeconds as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r" The supported range of 0-offset week day values when weeks start on"]
#[doc = r" Monday."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct WeekdayMondayZero(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for WeekdayMondayZero {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for WeekdayMondayZero { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for WeekdayMondayZero {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for WeekdayMondayZero {
const WHAT: &'static str = "weekday (Monday 0-indexed)";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = 6;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl WeekdayMondayZero {
pub const MIN: i8 = <WeekdayMondayZero as Bounds>::MIN;
pub const MAX: i8 = <WeekdayMondayZero as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::WeekdayMondayZero(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<WeekdayMondayZero as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::WeekdayMondayZero(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::WeekdayMondayZero(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<WeekdayMondayZero as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r" The supported range of 1-offset week day values when weeks start on"]
#[doc = r" Monday."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct WeekdayMondayOne(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for WeekdayMondayOne {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for WeekdayMondayOne { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for WeekdayMondayOne {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for WeekdayMondayOne {
const WHAT: &'static str = "weekday (Monday 1-indexed)";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = 7;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl WeekdayMondayOne {
pub const MIN: i8 = <WeekdayMondayOne as Bounds>::MIN;
pub const MAX: i8 = <WeekdayMondayOne as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::WeekdayMondayOne(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<WeekdayMondayOne as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::WeekdayMondayOne(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::WeekdayMondayOne(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<WeekdayMondayOne as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r" The supported range of 0-offset week day values when weeks start on"]
#[doc = r" Sunday."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct WeekdaySundayZero(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for WeekdaySundayZero {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for WeekdaySundayZero { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for WeekdaySundayZero {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for WeekdaySundayZero {
const WHAT: &'static str = "weekday (Sunday 0-indexed)";
const MIN: Self::Primitive = 0;
const MAX: Self::Primitive = 6;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl WeekdaySundayZero {
pub const MIN: i8 = <WeekdaySundayZero as Bounds>::MIN;
pub const MAX: i8 = <WeekdaySundayZero as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::WeekdaySundayZero(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<WeekdaySundayZero as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::WeekdaySundayZero(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::WeekdaySundayZero(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<WeekdaySundayZero as Bounds>::checked_mul(n1, n2)
}
}
#[doc =
r" The supported range of 1-offset week day values when weeks start on"]
#[doc = r" Sunday."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct WeekdaySundayOne(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for WeekdaySundayOne {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for WeekdaySundayOne { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for WeekdaySundayOne {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for WeekdaySundayOne {
const WHAT: &'static str = "weekday (Sunday 1-indexed)";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = 7;
type Primitive = i8;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl WeekdaySundayOne {
pub const MIN: i8 = <WeekdaySundayOne as Bounds>::MIN;
pub const MAX: i8 = <WeekdaySundayOne as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError {
kind: BoundsErrorKind::WeekdaySundayOne(RawBoundsError::new()),
}
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i8, BoundsError> {
<WeekdaySundayOne as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i8, BoundsError> {
match self::const_check::i8(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::WeekdaySundayOne(err),
}),
}
}
#[inline(always)]
pub const fn checked_add(n1: i8, n2: i8) -> Result<i8, BoundsError> {
match self::const_checked_add::i8(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError {
kind: BoundsErrorKind::WeekdaySundayOne(err),
}),
}
}
#[inline(always)]
pub fn checked_mul(n1: i8, n2: i8) -> Result<i8, BoundsError> {
<WeekdaySundayOne as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The range of years supported."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct Year(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for Year {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Year { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Year {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for Year {
const WHAT: &'static str = "year";
const MIN: Self::Primitive = -9999;
const MAX: Self::Primitive = 9999;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl Year {
pub const MIN: i16 = <Year as Bounds>::MIN;
pub const MAX: i16 = <Year as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::Year(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<Year as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) => Err(BoundsError { kind: BoundsErrorKind::Year(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) => Err(BoundsError { kind: BoundsErrorKind::Year(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<Year as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The range of years supported for the Common Era (CE)."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct YearCE(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for YearCE {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for YearCE { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for YearCE {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for YearCE {
const WHAT: &'static str = "CE year";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = Year::MAX;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl YearCE {
pub const MIN: i16 = <YearCE as Bounds>::MIN;
pub const MAX: i16 = <YearCE as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::YearCE(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<YearCE as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::YearCE(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::YearCE(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<YearCE as Bounds>::checked_mul(n1, n2)
}
}
#[doc = r" The range of years supported for Before Common Era (BCE)."]
#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
pub struct YearBCE(());
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::Eq for YearBCE {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<()>;
}
}
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for YearBCE { }
#[automatically_derived]#[allow(missing_debug_implementations)]
#[allow(missing_docs)]
impl ::core::cmp::PartialEq for YearBCE {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
impl Bounds for YearBCE {
const WHAT: &'static str = "BCE year";
const MIN: Self::Primitive = 1;
const MAX: Self::Primitive = Year::MAX + 1;
type Primitive = i16;
type Error = BoundsError;
#[cold]
#[inline(never)]
fn error() -> BoundsError { Self::error() }
}
#[allow(dead_code)]
#[allow(missing_docs)]
impl YearBCE {
pub const MIN: i16 = <YearBCE as Bounds>::MIN;
pub const MAX: i16 = <YearBCE as Bounds>::MAX;
pub const LEN: i128 = Self::MAX as i128 - Self::MIN as i128 + 1;
#[cold]
pub const fn error() -> BoundsError {
BoundsError { kind: BoundsErrorKind::YearBCE(RawBoundsError::new()) }
}
#[inline(always)]
pub fn check(n: impl Into<i64>) -> Result<i16, BoundsError> {
<YearBCE as Bounds>::check(n)
}
#[inline(always)]
pub const fn checkc(n: i64) -> Result<i16, BoundsError> {
match self::const_check::i16(n) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::YearBCE(err) }),
}
}
#[inline(always)]
pub const fn checked_add(n1: i16, n2: i16) -> Result<i16, BoundsError> {
match self::const_checked_add::i16(n1, n2) {
Ok(n) => Ok(n),
Err(err) =>
Err(BoundsError { kind: BoundsErrorKind::YearBCE(err) }),
}
}
#[inline(always)]
pub fn checked_mul(n1: i16, n2: i16) -> Result<i16, BoundsError> {
<YearBCE as Bounds>::checked_mul(n1, n2)
}
}
enum BoundsErrorKind {
CivilDayNanosecond(RawBoundsError<CivilDayNanosecond>),
CivilDaySecond(RawBoundsError<CivilDaySecond>),
Day(RawBoundsError<Day>),
DayOfYear(RawBoundsError<DayOfYear>),
DayOfYearNoLeap(RawBoundsError<DayOfYearNoLeap>),
DeltaSeconds(RawBoundsError<DeltaSeconds>),
Hour(RawBoundsError<Hour>),
ISOWeek(RawBoundsError<ISOWeek>),
ISOYear(RawBoundsError<ISOYear>),
Microsecond(RawBoundsError<Microsecond>),
Millisecond(RawBoundsError<Millisecond>),
Minute(RawBoundsError<Minute>),
Month(RawBoundsError<Month>),
Nanosecond(RawBoundsError<Nanosecond>),
NthWeekday(RawBoundsError<NthWeekday>),
NthWeekdayOfMonth(RawBoundsError<NthWeekdayOfMonth>),
OffsetHours(RawBoundsError<OffsetHours>),
OffsetMinutes(RawBoundsError<OffsetMinutes>),
OffsetSeconds(RawBoundsError<OffsetSeconds>),
OffsetTotalSeconds(RawBoundsError<OffsetTotalSeconds>),
Second(RawBoundsError<Second>),
SubsecNanosecond(RawBoundsError<SubsecNanosecond>),
SignedSubsecNanosecond(RawBoundsError<SignedSubsecNanosecond>),
TimestampArithmeticNanosecond(RawBoundsError<TimestampArithmeticNanosecond>),
UnixEpochDays(RawBoundsError<UnixEpochDays>),
UnixEpochMilliseconds(RawBoundsError<UnixEpochMilliseconds>),
UnixEpochMicroseconds(RawBoundsError<UnixEpochMicroseconds>),
UnixEpochSeconds(RawBoundsError<UnixEpochSeconds>),
WeekdayMondayZero(RawBoundsError<WeekdayMondayZero>),
WeekdayMondayOne(RawBoundsError<WeekdayMondayOne>),
WeekdaySundayZero(RawBoundsError<WeekdaySundayZero>),
WeekdaySundayOne(RawBoundsError<WeekdaySundayOne>),
Year(RawBoundsError<Year>),
YearCE(RawBoundsError<YearCE>),
YearBCE(RawBoundsError<YearBCE>),
}
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for BoundsErrorKind {
}
#[automatically_derived]impl ::core::clone::Clone for BoundsErrorKind {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _:
::core::clone::AssertParamIsClone<RawBoundsError<CivilDayNanosecond>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<CivilDaySecond>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Day>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<DayOfYear>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<DayOfYearNoLeap>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<DeltaSeconds>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Hour>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<ISOWeek>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<ISOYear>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Microsecond>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Millisecond>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Minute>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Month>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Nanosecond>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<NthWeekday>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<NthWeekdayOfMonth>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<OffsetHours>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<OffsetMinutes>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<OffsetSeconds>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<OffsetTotalSeconds>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Second>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<SubsecNanosecond>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<SignedSubsecNanosecond>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<TimestampArithmeticNanosecond>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<UnixEpochDays>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<UnixEpochMilliseconds>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<UnixEpochMicroseconds>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<UnixEpochSeconds>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<WeekdayMondayZero>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<WeekdayMondayOne>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<WeekdaySundayZero>>;
let _:
::core::clone::AssertParamIsClone<RawBoundsError<WeekdaySundayOne>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<Year>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<YearCE>>;
let _: ::core::clone::AssertParamIsClone<RawBoundsError<YearBCE>>;
*self
}
}
#[automatically_derived]impl ::core::marker::Copy for BoundsErrorKind { }
#[automatically_derived]impl ::core::fmt::Debug for BoundsErrorKind {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::CivilDayNanosecond(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"CivilDayNanosecond", &__self_0),
Self::CivilDaySecond(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"CivilDaySecond", &__self_0),
Self::Day(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Day",
&__self_0),
Self::DayOfYear(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"DayOfYear", &__self_0),
Self::DayOfYearNoLeap(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"DayOfYearNoLeap", &__self_0),
Self::DeltaSeconds(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"DeltaSeconds", &__self_0),
Self::Hour(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Hour",
&__self_0),
Self::ISOWeek(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"ISOWeek", &__self_0),
Self::ISOYear(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"ISOYear", &__self_0),
Self::Microsecond(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Microsecond", &__self_0),
Self::Millisecond(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Millisecond", &__self_0),
Self::Minute(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Minute", &__self_0),
Self::Month(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Month",
&__self_0),
Self::Nanosecond(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Nanosecond", &__self_0),
Self::NthWeekday(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"NthWeekday", &__self_0),
Self::NthWeekdayOfMonth(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"NthWeekdayOfMonth", &__self_0),
Self::OffsetHours(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"OffsetHours", &__self_0),
Self::OffsetMinutes(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"OffsetMinutes", &__self_0),
Self::OffsetSeconds(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"OffsetSeconds", &__self_0),
Self::OffsetTotalSeconds(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"OffsetTotalSeconds", &__self_0),
Self::Second(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Second", &__self_0),
Self::SubsecNanosecond(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"SubsecNanosecond", &__self_0),
Self::SignedSubsecNanosecond(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"SignedSubsecNanosecond", &__self_0),
Self::TimestampArithmeticNanosecond(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"TimestampArithmeticNanosecond", &__self_0),
Self::UnixEpochDays(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"UnixEpochDays", &__self_0),
Self::UnixEpochMilliseconds(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"UnixEpochMilliseconds", &__self_0),
Self::UnixEpochMicroseconds(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"UnixEpochMicroseconds", &__self_0),
Self::UnixEpochSeconds(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"UnixEpochSeconds", &__self_0),
Self::WeekdayMondayZero(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"WeekdayMondayZero", &__self_0),
Self::WeekdayMondayOne(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"WeekdayMondayOne", &__self_0),
Self::WeekdaySundayZero(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"WeekdaySundayZero", &__self_0),
Self::WeekdaySundayOne(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"WeekdaySundayOne", &__self_0),
Self::Year(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Year",
&__self_0),
Self::YearCE(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"YearCE", &__self_0),
Self::YearBCE(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"YearBCE", &__self_0),
}
}
}
#[automatically_derived]impl ::core::cmp::Eq for BoundsErrorKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<CivilDayNanosecond>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<CivilDaySecond>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Day>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<DayOfYear>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<DayOfYearNoLeap>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<DeltaSeconds>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Hour>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<ISOWeek>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<ISOYear>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Microsecond>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Millisecond>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Minute>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Month>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Nanosecond>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<NthWeekday>>;
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<NthWeekdayOfMonth>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<OffsetHours>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<OffsetMinutes>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<OffsetSeconds>>;
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<OffsetTotalSeconds>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Second>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<SubsecNanosecond>>;
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<SignedSubsecNanosecond>>;
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<TimestampArithmeticNanosecond>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<UnixEpochDays>>;
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<UnixEpochMilliseconds>>;
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<UnixEpochMicroseconds>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<UnixEpochSeconds>>;
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<WeekdayMondayZero>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<WeekdayMondayOne>>;
let _:
::core::cmp::AssertParamIsEq<RawBoundsError<WeekdaySundayZero>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<WeekdaySundayOne>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<Year>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<YearCE>>;
let _: ::core::cmp::AssertParamIsEq<RawBoundsError<YearBCE>>;
}
}
#[automatically_derived]impl ::core::marker::StructuralPartialEq for
BoundsErrorKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for BoundsErrorKind {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::CivilDayNanosecond(__self_0),
Self::CivilDayNanosecond(__arg1_0)) => __self_0 == __arg1_0,
(Self::CivilDaySecond(__self_0),
Self::CivilDaySecond(__arg1_0)) => __self_0 == __arg1_0,
(Self::Day(__self_0), Self::Day(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::DayOfYear(__self_0), Self::DayOfYear(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::DayOfYearNoLeap(__self_0),
Self::DayOfYearNoLeap(__arg1_0)) => __self_0 == __arg1_0,
(Self::DeltaSeconds(__self_0), Self::DeltaSeconds(__arg1_0))
=> __self_0 == __arg1_0,
(Self::Hour(__self_0), Self::Hour(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::ISOWeek(__self_0), Self::ISOWeek(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::ISOYear(__self_0), Self::ISOYear(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Microsecond(__self_0), Self::Microsecond(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Millisecond(__self_0), Self::Millisecond(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Minute(__self_0), Self::Minute(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Month(__self_0), Self::Month(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Nanosecond(__self_0), Self::Nanosecond(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::NthWeekday(__self_0), Self::NthWeekday(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::NthWeekdayOfMonth(__self_0),
Self::NthWeekdayOfMonth(__arg1_0)) => __self_0 == __arg1_0,
(Self::OffsetHours(__self_0), Self::OffsetHours(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::OffsetMinutes(__self_0), Self::OffsetMinutes(__arg1_0))
=> __self_0 == __arg1_0,
(Self::OffsetSeconds(__self_0), Self::OffsetSeconds(__arg1_0))
=> __self_0 == __arg1_0,
(Self::OffsetTotalSeconds(__self_0),
Self::OffsetTotalSeconds(__arg1_0)) => __self_0 == __arg1_0,
(Self::Second(__self_0), Self::Second(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::SubsecNanosecond(__self_0),
Self::SubsecNanosecond(__arg1_0)) => __self_0 == __arg1_0,
(Self::SignedSubsecNanosecond(__self_0),
Self::SignedSubsecNanosecond(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::TimestampArithmeticNanosecond(__self_0),
Self::TimestampArithmeticNanosecond(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::UnixEpochDays(__self_0), Self::UnixEpochDays(__arg1_0))
=> __self_0 == __arg1_0,
(Self::UnixEpochMilliseconds(__self_0),
Self::UnixEpochMilliseconds(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::UnixEpochMicroseconds(__self_0),
Self::UnixEpochMicroseconds(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::UnixEpochSeconds(__self_0),
Self::UnixEpochSeconds(__arg1_0)) => __self_0 == __arg1_0,
(Self::WeekdayMondayZero(__self_0),
Self::WeekdayMondayZero(__arg1_0)) => __self_0 == __arg1_0,
(Self::WeekdayMondayOne(__self_0),
Self::WeekdayMondayOne(__arg1_0)) => __self_0 == __arg1_0,
(Self::WeekdaySundayZero(__self_0),
Self::WeekdaySundayZero(__arg1_0)) => __self_0 == __arg1_0,
(Self::WeekdaySundayOne(__self_0),
Self::WeekdaySundayOne(__arg1_0)) => __self_0 == __arg1_0,
(Self::Year(__self_0), Self::Year(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::YearCE(__self_0), Self::YearCE(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::YearBCE(__self_0), Self::YearBCE(__arg1_0)) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}
impl core::fmt::Display for BoundsErrorKind {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match *self {
BoundsErrorKind::CivilDayNanosecond(ref err) => err.fmt(f),
BoundsErrorKind::CivilDaySecond(ref err) => err.fmt(f),
BoundsErrorKind::Day(ref err) => err.fmt(f),
BoundsErrorKind::DayOfYear(ref err) => err.fmt(f),
BoundsErrorKind::DayOfYearNoLeap(ref err) => err.fmt(f),
BoundsErrorKind::DeltaSeconds(ref err) => err.fmt(f),
BoundsErrorKind::Hour(ref err) => err.fmt(f),
BoundsErrorKind::ISOWeek(ref err) => err.fmt(f),
BoundsErrorKind::ISOYear(ref err) => err.fmt(f),
BoundsErrorKind::Microsecond(ref err) => err.fmt(f),
BoundsErrorKind::Millisecond(ref err) => err.fmt(f),
BoundsErrorKind::Minute(ref err) => err.fmt(f),
BoundsErrorKind::Month(ref err) => err.fmt(f),
BoundsErrorKind::Nanosecond(ref err) => err.fmt(f),
BoundsErrorKind::NthWeekday(ref err) => err.fmt(f),
BoundsErrorKind::NthWeekdayOfMonth(ref err) => err.fmt(f),
BoundsErrorKind::OffsetHours(ref err) => err.fmt(f),
BoundsErrorKind::OffsetMinutes(ref err) => err.fmt(f),
BoundsErrorKind::OffsetSeconds(ref err) => err.fmt(f),
BoundsErrorKind::OffsetTotalSeconds(ref err) => err.fmt(f),
BoundsErrorKind::Second(ref err) => err.fmt(f),
BoundsErrorKind::SubsecNanosecond(ref err) => err.fmt(f),
BoundsErrorKind::SignedSubsecNanosecond(ref err) => err.fmt(f),
BoundsErrorKind::TimestampArithmeticNanosecond(ref err) =>
err.fmt(f),
BoundsErrorKind::UnixEpochDays(ref err) => err.fmt(f),
BoundsErrorKind::UnixEpochMilliseconds(ref err) => err.fmt(f),
BoundsErrorKind::UnixEpochMicroseconds(ref err) => err.fmt(f),
BoundsErrorKind::UnixEpochSeconds(ref err) => err.fmt(f),
BoundsErrorKind::WeekdayMondayZero(ref err) => err.fmt(f),
BoundsErrorKind::WeekdayMondayOne(ref err) => err.fmt(f),
BoundsErrorKind::WeekdaySundayZero(ref err) => err.fmt(f),
BoundsErrorKind::WeekdaySundayOne(ref err) => err.fmt(f),
BoundsErrorKind::Year(ref err) => err.fmt(f),
BoundsErrorKind::YearCE(ref err) => err.fmt(f),
BoundsErrorKind::YearBCE(ref err) => err.fmt(f),
}
}
}define_bounds! {
140 (
142 CivilDayNanosecond,
143 i64,
144 "nanoseconds (in one civil day)",
145 0,
146 c::NANOS_PER_CIVIL_DAY - 1,
147 ),
148 (
150 CivilDaySecond,
151 i32,
152 "seconds (in one civil day)",
153 0,
154 c::SECS_PER_CIVIL_DAY_32 - 1,
155 ),
156 (Day, i8, "day", 1, 31),
162 (DayOfYear, i16, "day-of-year", 1, 366),
167 (DayOfYearNoLeap, i16, "day-of-year (skipping Feb 29)", 1, 365),
172 (
201 DeltaSeconds,
202 i64,
203 "seconds",
204 -Self::MAX,
205 next_multiple_of(
206 UnixEpochSeconds::LEN as i64
207 + OffsetTotalSeconds::MAX as i64
208 + c::SECS_PER_CIVIL_DAY,
209 c::SECS_PER_CIVIL_DAY,
210 ),
211 ),
212 (Hour, i8, "hour", 0, 23),
218 (ISOWeek, i8, "iso-week", 1, 53),
223 (ISOYear, i16, "iso-year", Year::MIN, Year::MAX),
227 (Microsecond, i16, "microsecond", 0, 999),
229 (Millisecond, i16, "millisecond", 0, 999),
231 (Minute, i8, "minute", 0, 59),
233 (Month, i8, "month", 1, 12),
235 (Nanosecond, i16, "nanosecond", 0, 999),
237 (
243 NthWeekday,
244 i32,
245 "nth weekday",
246 -Self::MAX,
247 (DeltaSeconds::MAX / c::SECS_PER_CIVIL_WEEK) as i32,
248 ),
249 (NthWeekdayOfMonth, i8, "nth weekday of month", -5, 5),
257 (OffsetHours, i8, "time zone offset hours", -25, 25),
278 (OffsetMinutes, i8, "time zone offset minutes", -59, 59),
280 (OffsetSeconds, i8, "time zone offset seconds", -59, 59),
282 (
285 OffsetTotalSeconds,
286 i32,
287 "time zone offset total seconds",
288 -Self::MAX,
289 (OffsetHours::MAX as i32 * c::SECS_PER_HOUR_32)
290 + (OffsetMinutes::MAX as i32 * c::MINS_PER_HOUR_32)
291 + OffsetSeconds::MAX as i32,
292 ),
293 (Second, i8, "second", 0, 59),
299 (SubsecNanosecond, i32, "subsecond nanosecond", 0, c::NANOS_PER_SEC_32 - 1),
302 (
308 SignedSubsecNanosecond,
309 i32,
310 "subsecond nanosecond",
311 -SubsecNanosecond::MAX,
312 SubsecNanosecond::MAX,
313 ),
314 (TimestampArithmeticNanosecond, i32, "nanosecond", i32::MIN, i32::MAX),
317 (
323 UnixEpochDays,
324 i32,
325 "Unix epoch days",
326 (UnixEpochSeconds::MIN + OffsetTotalSeconds::MIN as i64).div_euclid(c::SECS_PER_CIVIL_DAY) as i32,
327 (UnixEpochSeconds::MAX + OffsetTotalSeconds::MAX as i64).div_euclid(c::SECS_PER_CIVIL_DAY) as i32,
328 ),
329 (
330 UnixEpochMilliseconds,
331 i64,
332 "Unix timestamp milliseconds",
333 UnixEpochSeconds::MIN * c::MILLIS_PER_SEC,
334 (UnixEpochSeconds::MAX + 1) * c::MILLIS_PER_SEC - 1,
335 ),
336 (
337 UnixEpochMicroseconds,
338 i64,
339 "Unix timestamp microseconds",
340 UnixEpochMilliseconds::MIN * c::MICROS_PER_MILLI,
341 (UnixEpochMilliseconds::MAX + 1) * c::MICROS_PER_MILLI - 1,
342 ),
343 (
380 UnixEpochSeconds,
381 i64,
382 "Unix timestamp seconds",
383 -377705116800 - OffsetTotalSeconds::MIN as i64,
384 253402300799 - OffsetTotalSeconds::MAX as i64,
385 ),
386 (WeekdayMondayZero, i8, "weekday (Monday 0-indexed)", 0, 6),
389 (WeekdayMondayOne, i8, "weekday (Monday 1-indexed)", 1, 7),
392 (WeekdaySundayZero, i8, "weekday (Sunday 0-indexed)", 0, 6),
395 (WeekdaySundayOne, i8, "weekday (Sunday 1-indexed)", 1, 7),
398 (Year, i16, "year", -9999, 9999),
400 (YearCE, i16, "CE year", 1, Year::MAX),
402 (YearBCE, i16, "BCE year", 1, Year::MAX + 1),
404}
405
406#[allow(missing_docs)]
417pub trait Primitive:
418 Clone
419 + Copy
420 + Eq
421 + PartialEq
422 + PartialOrd
423 + Ord
424 + core::fmt::Debug
425 + core::fmt::Display
426{
427 fn as_i8(self) -> i8;
428 fn as_i16(self) -> i16;
429 fn as_i32(self) -> i32;
430 fn as_i64(self) -> i64;
431
432 fn from_i8(n: i8) -> Self;
433 fn from_i16(n: i16) -> Self;
434 fn from_i32(n: i32) -> Self;
435 fn from_i64(n: i64) -> Self;
436
437 fn checked_add(self, n: Self) -> Option<Self>;
438 fn checked_mul(self, n: Self) -> Option<Self>;
439}
440
441macro_rules! impl_primitive {
442 ($($intty:ty),*) => {
443 $(
444 impl Primitive for $intty {
445 fn as_i8(self) -> i8 {
446 #[cfg(debug_assertions)]
447 {
448 i8::try_from(self).unwrap()
449 }
450 #[cfg(not(debug_assertions))]
451 {
452 self as i8
453 }
454 }
455
456 fn as_i16(self) -> i16 {
457 #[cfg(debug_assertions)]
458 {
459 i16::try_from(self).unwrap()
460 }
461 #[cfg(not(debug_assertions))]
462 {
463 self as i16
464 }
465 }
466
467 fn as_i32(self) -> i32 {
468 #[cfg(debug_assertions)]
469 {
470 i32::try_from(self).unwrap()
471 }
472 #[cfg(not(debug_assertions))]
473 {
474 self as i32
475 }
476 }
477
478 fn as_i64(self) -> i64 {
479 #[cfg(debug_assertions)]
480 {
481 i64::try_from(self).unwrap()
482 }
483 #[cfg(not(debug_assertions))]
484 {
485 self as i64
486 }
487 }
488
489 fn from_i8(n: i8) -> Self {
490 #[cfg(debug_assertions)]
491 {
492 Self::try_from(n).unwrap()
493 }
494 #[cfg(not(debug_assertions))]
495 {
496 n as Self
497 }
498 }
499
500 fn from_i16(n: i16) -> Self {
501 #[cfg(debug_assertions)]
502 {
503 Self::try_from(n).unwrap()
504 }
505 #[cfg(not(debug_assertions))]
506 {
507 n as Self
508 }
509 }
510
511 fn from_i32(n: i32) -> Self {
512 #[cfg(debug_assertions)]
513 {
514 Self::try_from(n).unwrap()
515 }
516 #[cfg(not(debug_assertions))]
517 {
518 n as Self
519 }
520 }
521
522 fn from_i64(n: i64) -> Self {
523 #[cfg(debug_assertions)]
524 {
525 Self::try_from(n).unwrap()
526 }
527 #[cfg(not(debug_assertions))]
528 {
529 n as Self
530 }
531 }
532
533 fn checked_add(self, n: $intty) -> Option<$intty> {
534 <$intty>::checked_add(self, n)
535 }
536
537 fn checked_mul(self, n: $intty) -> Option<$intty> {
538 <$intty>::checked_mul(self, n)
539 }
540 }
541 )*
542 }
543}
544
545impl Primitive for i8 {
fn as_i8(self) -> i8 { { i8::try_from(self).unwrap() } }
fn as_i16(self) -> i16 { { i16::try_from(self).unwrap() } }
fn as_i32(self) -> i32 { { i32::try_from(self).unwrap() } }
fn as_i64(self) -> i64 { { i64::try_from(self).unwrap() } }
fn from_i8(n: i8) -> Self { { Self::try_from(n).unwrap() } }
fn from_i16(n: i16) -> Self { { Self::try_from(n).unwrap() } }
fn from_i32(n: i32) -> Self { { Self::try_from(n).unwrap() } }
fn from_i64(n: i64) -> Self { { Self::try_from(n).unwrap() } }
fn checked_add(self, n: i8) -> Option<i8> { <i8>::checked_add(self, n) }
fn checked_mul(self, n: i8) -> Option<i8> { <i8>::checked_mul(self, n) }
}
impl Primitive for i16 {
fn as_i8(self) -> i8 { { i8::try_from(self).unwrap() } }
fn as_i16(self) -> i16 { { i16::try_from(self).unwrap() } }
fn as_i32(self) -> i32 { { i32::try_from(self).unwrap() } }
fn as_i64(self) -> i64 { { i64::try_from(self).unwrap() } }
fn from_i8(n: i8) -> Self { { Self::try_from(n).unwrap() } }
fn from_i16(n: i16) -> Self { { Self::try_from(n).unwrap() } }
fn from_i32(n: i32) -> Self { { Self::try_from(n).unwrap() } }
fn from_i64(n: i64) -> Self { { Self::try_from(n).unwrap() } }
fn checked_add(self, n: i16) -> Option<i16> {
<i16>::checked_add(self, n)
}
fn checked_mul(self, n: i16) -> Option<i16> {
<i16>::checked_mul(self, n)
}
}
impl Primitive for i32 {
fn as_i8(self) -> i8 { { i8::try_from(self).unwrap() } }
fn as_i16(self) -> i16 { { i16::try_from(self).unwrap() } }
fn as_i32(self) -> i32 { { i32::try_from(self).unwrap() } }
fn as_i64(self) -> i64 { { i64::try_from(self).unwrap() } }
fn from_i8(n: i8) -> Self { { Self::try_from(n).unwrap() } }
fn from_i16(n: i16) -> Self { { Self::try_from(n).unwrap() } }
fn from_i32(n: i32) -> Self { { Self::try_from(n).unwrap() } }
fn from_i64(n: i64) -> Self { { Self::try_from(n).unwrap() } }
fn checked_add(self, n: i32) -> Option<i32> {
<i32>::checked_add(self, n)
}
fn checked_mul(self, n: i32) -> Option<i32> {
<i32>::checked_mul(self, n)
}
}
impl Primitive for i64 {
fn as_i8(self) -> i8 { { i8::try_from(self).unwrap() } }
fn as_i16(self) -> i16 { { i16::try_from(self).unwrap() } }
fn as_i32(self) -> i32 { { i32::try_from(self).unwrap() } }
fn as_i64(self) -> i64 { { i64::try_from(self).unwrap() } }
fn from_i8(n: i8) -> Self { { Self::try_from(n).unwrap() } }
fn from_i16(n: i16) -> Self { { Self::try_from(n).unwrap() } }
fn from_i32(n: i32) -> Self { { Self::try_from(n).unwrap() } }
fn from_i64(n: i64) -> Self { { Self::try_from(n).unwrap() } }
fn checked_add(self, n: i64) -> Option<i64> {
<i64>::checked_add(self, n)
}
fn checked_mul(self, n: i64) -> Option<i64> {
<i64>::checked_mul(self, n)
}
}impl_primitive!(i8, i16, i32, i64);
546
547pub trait Bounds: Sized {
642 const WHAT: &'static str;
645
646 const MIN: Self::Primitive;
648
649 const MAX: Self::Primitive;
651
652 type Primitive: Primitive;
657
658 type Error;
667
668 fn error() -> Self::Error;
670
671 #[inline(always)]
679 fn check(n: impl Into<i64>) -> Result<Self::Primitive, Self::Error> {
680 let n = n.into();
681 if !(Self::MIN.as_i64() <= n && n <= Self::MAX.as_i64()) {
682 return Err(Self::error());
683 }
684 Ok(Self::Primitive::from_i64(n))
685 }
686
687 #[inline(always)]
695 fn check_self(n: Self::Primitive) -> Result<Self::Primitive, Self::Error> {
696 if !(Self::MIN <= n && n <= Self::MAX) {
697 return Err(Self::error());
698 }
699 Ok(n)
700 }
701
702 #[inline(always)]
710 fn checked_add(
711 n1: Self::Primitive,
712 n2: Self::Primitive,
713 ) -> Result<Self::Primitive, Self::Error> {
714 Self::check_self(n1.checked_add(n2).ok_or_else(Self::error)?)
715 }
716
717 #[inline(always)]
725 fn checked_mul(
726 n1: Self::Primitive,
727 n2: Self::Primitive,
728 ) -> Result<Self::Primitive, Self::Error> {
729 Self::check_self(n1.checked_mul(n2).ok_or_else(Self::error)?)
730 }
731}
732
733#[derive(#[automatically_derived]impl<B: ::core::cmp::Eq> ::core::cmp::Eq for
RawBoundsError<B> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<core::marker::PhantomData<B>>;
}
}Eq, #[automatically_derived]impl<B: ::core::cmp::PartialEq>
::core::marker::StructuralPartialEq for RawBoundsError<B> {
}
#[automatically_derived]impl<B: ::core::cmp::PartialEq> ::core::cmp::PartialEq
for RawBoundsError<B> {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq)]
739pub struct RawBoundsError<B>(core::marker::PhantomData<B>);
740
741impl<B> RawBoundsError<B> {
742 #[inline]
748 pub const fn new() -> RawBoundsError<B> {
749 RawBoundsError(core::marker::PhantomData)
750 }
751}
752
753impl<B> Copy for RawBoundsError<B> {}
754
755impl<B> Clone for RawBoundsError<B> {
756 #[inline]
757 fn clone(&self) -> RawBoundsError<B> {
758 RawBoundsError::new()
759 }
760}
761
762impl<B, P> core::fmt::Debug for RawBoundsError<B>
763where
764 B: Bounds<Primitive = P>,
765 P: core::fmt::Debug,
766{
767 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
768 f.debug_struct("RawBoundsError")
769 .field("what", &B::WHAT)
770 .field("min", &B::MIN)
771 .field("max", &B::MAX)
772 .finish()
773 }
774}
775
776impl<B, P> core::fmt::Display for RawBoundsError<B>
777where
778 B: Bounds<Primitive = P>,
779 P: core::fmt::Display,
780{
781 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
782 f.write_fmt(format_args!("parameter \'{0}\' is not in the required range of {1}..={2}",
B::WHAT, B::MIN, B::MAX))write!(
783 f,
784 "parameter '{what}' is not in the required range of {min}..={max}",
785 what = B::WHAT,
786 min = B::MIN,
787 max = B::MAX,
788 )
789 }
790}
791
792#[cfg(feature = "defmt")]
793impl<B, P> defmt::Format for RawBoundsError<B>
794where
795 B: Bounds<Primitive = P>,
796 P: defmt::Format,
797{
798 fn format(&self, f: defmt::Formatter) {
799 defmt::write!(
800 f,
801 "RawBoundsError {{ what: {=str}, min: {}, max: {} }}",
802 B::WHAT,
803 B::MIN,
804 B::MAX
805 );
806 }
807}
808
809#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for BoundsError {
}
#[automatically_derived]impl ::core::clone::Clone for BoundsError {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<BoundsErrorKind>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for BoundsError { }Copy, #[automatically_derived]impl ::core::fmt::Debug for BoundsError {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"BoundsError kind", &&self.kind)
}
}Debug, #[automatically_derived]impl ::core::cmp::Eq for BoundsError {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<BoundsErrorKind>;
}
}Eq, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
BoundsError {
}
#[automatically_derived]impl ::core::cmp::PartialEq for BoundsError {
#[inline]
fn eq(&self, other: &Self) -> bool { self.kind == other.kind }
}PartialEq)]
817#[cfg_attr(feature = "defmt", derive(defmt::Format))]
818pub struct BoundsError {
819 kind: BoundsErrorKind,
820}
821
822impl BoundsError {
823 pub(crate) const fn into_range_error(self) -> RangeError {
824 RangeError { kind: RangeErrorKind::Bounds(self) }
825 }
826}
827
828impl core::fmt::Display for BoundsError {
829 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
830 self.kind.fmt(f)
831 }
832}
833
834#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for RangeError {
}
#[automatically_derived]impl ::core::clone::Clone for RangeError {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<RangeErrorKind>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for RangeError { }Copy, #[automatically_derived]impl ::core::fmt::Debug for RangeError {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"RangeError kind", &&self.kind)
}
}Debug, #[automatically_derived]impl ::core::cmp::Eq for RangeError {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<RangeErrorKind>;
}
}Eq, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
RangeError {
}
#[automatically_derived]impl ::core::cmp::PartialEq for RangeError {
#[inline]
fn eq(&self, other: &Self) -> bool { self.kind == other.kind }
}PartialEq)]
840#[cfg_attr(feature = "defmt", derive(defmt::Format))]
841pub struct RangeError {
842 kind: RangeErrorKind,
843}
844
845impl From<BoundsError> for RangeError {
846 fn from(err: BoundsError) -> RangeError {
847 err.into_range_error()
848 }
849}
850
851impl From<SpecialBoundsError> for RangeError {
852 fn from(err: SpecialBoundsError) -> RangeError {
853 err.into_range_error()
854 }
855}
856
857impl core::fmt::Display for RangeError {
858 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
859 match self.kind {
860 RangeErrorKind::Bounds(ref err) => err.fmt(f),
861 RangeErrorKind::Special(ref err) => err.fmt(f),
862 }
863 }
864}
865
866impl core::error::Error for RangeError {}
867
868#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for RangeErrorKind {
}
#[automatically_derived]impl ::core::clone::Clone for RangeErrorKind {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<BoundsError>;
let _: ::core::clone::AssertParamIsClone<SpecialBoundsError>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for RangeErrorKind { }Copy, #[automatically_derived]impl ::core::fmt::Debug for RangeErrorKind {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::Bounds(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Bounds", &__self_0),
Self::Special(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Special", &__self_0),
}
}
}Debug, #[automatically_derived]impl ::core::cmp::Eq for RangeErrorKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<BoundsError>;
let _: ::core::cmp::AssertParamIsEq<SpecialBoundsError>;
}
}Eq, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
RangeErrorKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for RangeErrorKind {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Bounds(__self_0), Self::Bounds(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Special(__self_0), Self::Special(__arg1_0)) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq)]
869#[cfg_attr(feature = "defmt", derive(defmt::Format))]
870enum RangeErrorKind {
871 Bounds(BoundsError),
872 Special(SpecialBoundsError),
873}
874
875#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for SpecialBoundsError {
}
#[automatically_derived]impl ::core::clone::Clone for SpecialBoundsError {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<i16>;
let _: ::core::clone::AssertParamIsClone<i8>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for SpecialBoundsError { }Copy, #[automatically_derived]impl ::core::fmt::Debug for SpecialBoundsError {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::DateInvalidDay { year: __self_0, month: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DateInvalidDay year month", __self_0, &__self_1),
Self::DateInvalidDayOfYear { year: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"DateInvalidDayOfYear year", &__self_0),
Self::UnixEpochNanoseconds =>
::core::fmt::Formatter::write_str(f, "UnixEpochNanoseconds"),
}
}
}Debug, #[automatically_derived]impl ::core::cmp::Eq for SpecialBoundsError {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<i16>;
let _: ::core::cmp::AssertParamIsEq<i8>;
}
}Eq, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
SpecialBoundsError {
}
#[automatically_derived]impl ::core::cmp::PartialEq for SpecialBoundsError {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::DateInvalidDay { year: __self_0, month: __self_1 },
Self::DateInvalidDay { year: __arg1_0, month: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(Self::DateInvalidDayOfYear { year: __self_0 },
Self::DateInvalidDayOfYear { year: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq)]
876#[cfg_attr(feature = "defmt", derive(defmt::Format))]
877pub(crate) enum SpecialBoundsError {
878 DateInvalidDay { year: i16, month: i8 },
879 DateInvalidDayOfYear { year: i16 },
880 UnixEpochNanoseconds,
881}
882
883impl SpecialBoundsError {
884 pub(crate) const fn into_range_error(self) -> RangeError {
885 RangeError { kind: RangeErrorKind::Special(self) }
886 }
887}
888
889impl core::fmt::Display for SpecialBoundsError {
890 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
891 use self::SpecialBoundsError::*;
892
893 match *self {
894 DateInvalidDay { year, month } => f.write_fmt(format_args!("parameter \'day\' for `{1:04}-{2:02}` is invalid, must be in range `1..={0}`",
crate::civil::days_in_month(year, month), year, month))write!(
895 f,
896 "parameter 'day' for `{year:04}-{month:02}` is invalid, \
897 must be in range `1..={max_day}`",
898 max_day = crate::civil::days_in_month(year, month),
899 ),
900 DateInvalidDayOfYear { year } => f.write_fmt(format_args!("number of days for `{1:04}` is invalid, must be in range `1..={0}`",
crate::civil::days_in_year(year), year))write!(
901 f,
902 "number of days for `{year:04}` is invalid, \
903 must be in range `1..={max_day}`",
904 max_day = crate::civil::days_in_year(year),
905 ),
906 UnixEpochNanoseconds => f.write_fmt(format_args!("parameter \'Unix timestamp nanoseconds\' is not in the required range of {0}..={1}",
crate::Timestamp::MIN.as_nanosecond(),
crate::Timestamp::MAX.as_nanosecond()))write!(
907 f,
908 "parameter 'Unix timestamp nanoseconds' \
909 is not in the required range of {min}..={max}",
910 min = crate::Timestamp::MIN.as_nanosecond(),
911 max = crate::Timestamp::MAX.as_nanosecond(),
912 ),
913 }
914 }
915}
916
917#[allow(missing_docs)]
922pub mod const_check {
923 use super::{Bounds, RawBoundsError};
924
925 #[inline(always)]
926 pub const fn i8<B>(n: i64) -> Result<i8, RawBoundsError<B>>
927 where
928 B: Bounds<Primitive = i8>,
929 {
930 if !((B::MIN as i64) <= n && n <= (B::MAX as i64)) {
931 return Err(RawBoundsError::new());
932 }
933 Ok(n as i8)
934 }
935
936 #[inline(always)]
937 pub const fn i16<B>(n: i64) -> Result<i16, RawBoundsError<B>>
938 where
939 B: Bounds<Primitive = i16>,
940 {
941 if !((B::MIN as i64) <= n && n <= (B::MAX as i64)) {
942 return Err(RawBoundsError::new());
943 }
944 Ok(n as i16)
945 }
946
947 #[inline(always)]
948 pub const fn i32<B>(n: i64) -> Result<i32, RawBoundsError<B>>
949 where
950 B: Bounds<Primitive = i32>,
951 {
952 if !((B::MIN as i64) <= n && n <= (B::MAX as i64)) {
953 return Err(RawBoundsError::new());
954 }
955 Ok(n as i32)
956 }
957
958 #[inline(always)]
959 pub const fn i64<B>(n: i64) -> Result<i64, RawBoundsError<B>>
960 where
961 B: Bounds<Primitive = i64>,
962 {
963 if !(B::MIN <= n && n <= B::MAX) {
964 return Err(RawBoundsError::new());
965 }
966 Ok(n)
967 }
968}
969
970#[allow(missing_docs)]
975pub mod const_checked_add {
976 use super::{Bounds, RawBoundsError};
977
978 #[inline(always)]
979 pub const fn i8<B>(n1: i8, n2: i8) -> Result<i8, RawBoundsError<B>>
980 where
981 B: Bounds<Primitive = i8>,
982 {
983 let sum = match n1.checked_add(n2) {
984 Some(sum) => sum,
985 None => return Err(RawBoundsError::new()),
986 };
987 super::const_check::i8(sum as i64)
988 }
989
990 #[inline(always)]
991 pub const fn i16<B>(n1: i16, n2: i16) -> Result<i16, RawBoundsError<B>>
992 where
993 B: Bounds<Primitive = i16>,
994 {
995 let sum = match n1.checked_add(n2) {
996 Some(sum) => sum,
997 None => return Err(RawBoundsError::new()),
998 };
999 super::const_check::i16(sum as i64)
1000 }
1001
1002 #[inline(always)]
1003 pub const fn i32<B>(n1: i32, n2: i32) -> Result<i32, RawBoundsError<B>>
1004 where
1005 B: Bounds<Primitive = i32>,
1006 {
1007 let sum = match n1.checked_add(n2) {
1008 Some(sum) => sum,
1009 None => return Err(RawBoundsError::new()),
1010 };
1011 super::const_check::i32(sum as i64)
1012 }
1013
1014 #[inline(always)]
1015 pub const fn i64<B>(n1: i64, n2: i64) -> Result<i64, RawBoundsError<B>>
1016 where
1017 B: Bounds<Primitive = i64>,
1018 {
1019 let sum = match n1.checked_add(n2) {
1020 Some(sum) => sum,
1021 None => return Err(RawBoundsError::new()),
1022 };
1023 super::const_check::i64(sum)
1024 }
1025}
1026
1027#[derive(
1032 #[automatically_derived]#[doc(hidden)]#[allow(missing_docs)]
unsafe impl ::core::clone::TrivialClone for Sign { }
#[automatically_derived]#[allow(missing_docs)]
impl ::core::clone::Clone for Sign {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]#[allow(missing_docs)]
impl ::core::marker::Copy for Sign { }Copy, #[automatically_derived]#[allow(missing_docs)]
impl ::core::fmt::Debug for Sign {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Sign::Zero => "Zero",
Sign::Positive => "Positive",
Sign::Negative => "Negative",
})
}
}Debug, #[automatically_derived]#[allow(missing_docs)]
impl ::core::default::Default for Sign {
#[inline]
fn default() -> Self { Self::Zero }
}Default, #[automatically_derived]#[allow(missing_docs)]
impl ::core::cmp::Eq for Sign { }Eq, #[automatically_derived]#[allow(missing_docs)]
impl ::core::hash::Hash for Sign {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]#[allow(missing_docs)]
impl ::core::marker::StructuralPartialEq for Sign { }
#[automatically_derived]#[allow(missing_docs)]
impl ::core::cmp::PartialEq for Sign {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]#[allow(missing_docs)]
impl ::core::cmp::PartialOrd for Sign {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]#[allow(missing_docs)]
impl ::core::cmp::Ord for Sign {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord,
1033)]
1034#[repr(i8)]
1035#[allow(missing_docs)]
1036pub enum Sign {
1037 #[default]
1038 Zero = 0,
1039 Positive = 1,
1040 Negative = -1,
1041}
1042
1043impl Sign {
1044 #[inline]
1046 pub const fn is_zero(self) -> bool {
1047 #[allow(non_exhaustive_omitted_patterns)] match self {
Sign::Zero => true,
_ => false,
}matches!(self, Sign::Zero)
1048 }
1049
1050 #[inline]
1052 pub const fn is_positive(self) -> bool {
1053 #[allow(non_exhaustive_omitted_patterns)] match self {
Sign::Positive => true,
_ => false,
}matches!(self, Sign::Positive)
1054 }
1055
1056 #[inline]
1058 pub const fn is_negative(self) -> bool {
1059 #[allow(non_exhaustive_omitted_patterns)] match self {
Sign::Negative => true,
_ => false,
}matches!(self, Sign::Negative)
1060 }
1061
1062 #[inline]
1066 pub const fn signum(self) -> i8 {
1067 self.as_i8()
1068 }
1069
1070 #[inline]
1074 pub const fn as_i8(self) -> i8 {
1075 self as i8
1076 }
1077
1078 #[inline]
1082 pub const fn as_i16(self) -> i16 {
1083 self as i16
1084 }
1085
1086 #[inline]
1090 pub const fn as_i32(self) -> i32 {
1091 self as i32
1092 }
1093
1094 #[inline]
1098 pub const fn as_i64(self) -> i64 {
1099 self as i64
1100 }
1101
1102 #[inline]
1106 pub const fn as_i128(self) -> i128 {
1107 self as i128
1108 }
1109
1110 #[inline]
1116 pub fn from_ordinals<T: Ord>(t1: T, t2: T) -> Sign {
1117 use core::cmp::Ordering::*;
1118 match t1.cmp(&t2) {
1119 Less => Sign::Negative,
1120 Equal => Sign::Zero,
1121 Greater => Sign::Positive,
1122 }
1123 }
1124}
1125
1126impl core::fmt::Display for Sign {
1127 #[inline]
1128 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1129 if self.is_negative() { f.write_str("-") } else { Ok(()) }
1130 }
1131}
1132
1133impl core::ops::Neg for Sign {
1134 type Output = Sign;
1135
1136 #[inline]
1137 fn neg(self) -> Sign {
1138 match self {
1139 Sign::Positive => Sign::Negative,
1140 Sign::Zero => Sign::Zero,
1141 Sign::Negative => Sign::Positive,
1142 }
1143 }
1144}
1145
1146impl From<i8> for Sign {
1147 #[inline]
1148 fn from(n: i8) -> Sign {
1149 Sign::from(i64::from(n))
1150 }
1151}
1152
1153impl From<i16> for Sign {
1154 #[inline]
1155 fn from(n: i16) -> Sign {
1156 Sign::from(i64::from(n))
1157 }
1158}
1159
1160impl From<i32> for Sign {
1161 #[inline]
1162 fn from(n: i32) -> Sign {
1163 Sign::from(i64::from(n))
1164 }
1165}
1166
1167impl From<i64> for Sign {
1168 #[inline]
1169 fn from(n: i64) -> Sign {
1170 if n == 0 {
1171 Sign::Zero
1172 } else if n > 0 {
1173 Sign::Positive
1174 } else {
1175 Sign::Negative
1176 }
1177 }
1178}
1179
1180impl From<i128> for Sign {
1181 #[inline]
1182 fn from(n: i128) -> Sign {
1183 if n == 0 {
1184 Sign::Zero
1185 } else if n > 0 {
1186 Sign::Positive
1187 } else {
1188 Sign::Negative
1189 }
1190 }
1191}
1192
1193impl From<f64> for Sign {
1197 #[inline]
1198 fn from(n: f64) -> Sign {
1199 use core::num::FpCategory::*;
1200
1201 if #[allow(non_exhaustive_omitted_patterns)] match n.classify() {
Nan | Zero => true,
_ => false,
}matches!(n.classify(), Nan | Zero) {
1212 Sign::Zero
1213 } else if n.is_sign_positive() {
1214 Sign::Positive
1215 } else {
1216 Sign::Negative
1217 }
1218 }
1219}
1220
1221impl core::ops::Mul<Sign> for Sign {
1222 type Output = Sign;
1223
1224 #[inline]
1225 fn mul(self, rhs: Sign) -> Sign {
1226 match (self, rhs) {
1227 (Sign::Zero, _) | (_, Sign::Zero) => Sign::Zero,
1228 (Sign::Positive, Sign::Positive) => Sign::Positive,
1229 (Sign::Negative, Sign::Negative) => Sign::Positive,
1230 (Sign::Positive, Sign::Negative) => Sign::Negative,
1231 (Sign::Negative, Sign::Positive) => Sign::Negative,
1232 }
1233 }
1234}
1235
1236impl core::ops::Mul<i8> for Sign {
1237 type Output = i8;
1238
1239 #[inline]
1240 fn mul(self, n: i8) -> i8 {
1241 self.as_i8() * n
1242 }
1243}
1244
1245impl core::ops::Mul<Sign> for i8 {
1246 type Output = i8;
1247
1248 #[inline]
1249 fn mul(self, n: Sign) -> i8 {
1250 self * n.as_i8()
1251 }
1252}
1253
1254impl core::ops::Mul<i16> for Sign {
1255 type Output = i16;
1256
1257 #[inline]
1258 fn mul(self, n: i16) -> i16 {
1259 self.as_i16() * n
1260 }
1261}
1262
1263impl core::ops::Mul<Sign> for i16 {
1264 type Output = i16;
1265
1266 #[inline]
1267 fn mul(self, n: Sign) -> i16 {
1268 self * n.as_i16()
1269 }
1270}
1271
1272impl core::ops::Mul<i32> for Sign {
1273 type Output = i32;
1274
1275 #[inline]
1276 fn mul(self, n: i32) -> i32 {
1277 self.as_i32() * n
1278 }
1279}
1280
1281impl core::ops::Mul<Sign> for i32 {
1282 type Output = i32;
1283
1284 #[inline]
1285 fn mul(self, n: Sign) -> i32 {
1286 self * n.as_i32()
1287 }
1288}
1289
1290impl core::ops::Mul<i64> for Sign {
1291 type Output = i64;
1292
1293 #[inline]
1294 fn mul(self, n: i64) -> i64 {
1295 self.as_i64() * n
1296 }
1297}
1298
1299impl core::ops::Mul<Sign> for i64 {
1300 type Output = i64;
1301
1302 #[inline]
1303 fn mul(self, n: Sign) -> i64 {
1304 self * n.as_i64()
1305 }
1306}
1307
1308impl core::ops::Mul<i128> for Sign {
1309 type Output = i128;
1310
1311 #[inline]
1312 fn mul(self, n: i128) -> i128 {
1313 self.as_i128() * n
1314 }
1315}
1316
1317impl core::ops::Mul<Sign> for i128 {
1318 type Output = i128;
1319
1320 #[inline]
1321 fn mul(self, n: Sign) -> i128 {
1322 self * n.as_i128()
1323 }
1324}
1325
1326const fn next_multiple_of(lhs: i64, rhs: i64) -> i64 {
1331 if rhs == -1 {
1333 return lhs;
1334 }
1335
1336 let r = lhs % rhs;
1337 let m = if (r > 0 && rhs < 0) || (r < 0 && rhs > 0) { r + rhs } else { r };
1338 if m == 0 { lhs } else { lhs + (rhs - m) }
1339}