1use crate::error;
2
3#[derive(#[automatically_derived]impl ::core::clone::Clone for Error {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
match self {
Self::FailedAddDays => Error::FailedAddDays,
Self::FailedAddDurationOverflowing =>
Error::FailedAddDurationOverflowing,
Self::FailedAddSpanDate => Error::FailedAddSpanDate,
Self::FailedAddSpanOverflowing => Error::FailedAddSpanOverflowing,
Self::FailedAddSpanTime => Error::FailedAddSpanTime,
Self::IllegalTimeWithMicrosecond =>
Error::IllegalTimeWithMicrosecond,
Self::IllegalTimeWithMillisecond =>
Error::IllegalTimeWithMillisecond,
Self::IllegalTimeWithNanosecond =>
Error::IllegalTimeWithNanosecond,
Self::OverflowDaysDuration => Error::OverflowDaysDuration,
Self::OverflowTimeNanoseconds => Error::OverflowTimeNanoseconds,
}
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Error {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_c_like_enum_write_str(f,
"FailedAddDays FailedAddDurationOverflowing FailedAddSpanDate FailedAddSpanOverflowing FailedAddSpanTime IllegalTimeWithMicrosecond IllegalTimeWithMillisecond IllegalTimeWithNanosecond OverflowDaysDuration OverflowTimeNanoseconds",
match self {
Error::FailedAddDays => 0usize,
Error::FailedAddDurationOverflowing => 14usize,
Error::FailedAddSpanDate => 43usize,
Error::FailedAddSpanOverflowing => 61usize,
Error::FailedAddSpanTime => 86usize,
Error::IllegalTimeWithMicrosecond => 104usize,
Error::IllegalTimeWithMillisecond => 131usize,
Error::IllegalTimeWithNanosecond => 158usize,
Error::OverflowDaysDuration => 184usize,
Error::OverflowTimeNanoseconds => 205usize,
})
}
}Debug)]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5pub(crate) enum Error {
6 FailedAddDays,
7 FailedAddDurationOverflowing,
8 FailedAddSpanDate,
9 FailedAddSpanOverflowing,
10 FailedAddSpanTime,
11 IllegalTimeWithMicrosecond,
12 IllegalTimeWithMillisecond,
13 IllegalTimeWithNanosecond,
14 OverflowDaysDuration,
15 OverflowTimeNanoseconds,
16}
17
18impl From<Error> for error::Error {
19 #[cold]
20 #[inline(never)]
21 fn from(err: Error) -> error::Error {
22 error::ErrorKind::Civil(err).into()
23 }
24}
25
26impl error::IntoError for Error {
27 fn into_error(self) -> error::Error {
28 self.into()
29 }
30}
31
32impl core::fmt::Display for Error {
33 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
34 use self::Error::*;
35
36 match *self {
37 FailedAddDays => f.write_str("failed to add days to date"),
38 FailedAddDurationOverflowing => {
39 f.write_str("failed to add overflowing duration")
40 }
41 FailedAddSpanDate => f.write_str("failed to add span to date"),
42 FailedAddSpanOverflowing => {
43 f.write_str("failed to add overflowing span")
44 }
45 FailedAddSpanTime => f.write_str("failed to add span to time"),
46 IllegalTimeWithMicrosecond => f.write_str(
47 "cannot set both `TimeWith::microsecond` \
48 and `TimeWith::subsec_nanosecond`",
49 ),
50 IllegalTimeWithMillisecond => f.write_str(
51 "cannot set both `TimeWith::millisecond` \
52 and `TimeWith::subsec_nanosecond`",
53 ),
54 IllegalTimeWithNanosecond => f.write_str(
55 "cannot set both `TimeWith::nanosecond` \
56 and `TimeWith::subsec_nanosecond`",
57 ),
58 OverflowDaysDuration => f.write_str(
59 "number of days derived from duration exceed's \
60 Jiff's datetime limits",
61 ),
62 OverflowTimeNanoseconds => {
63 f.write_str("adding duration to time overflowed")
64 }
65 }
66 }
67}