satellite_datetime/
error.rs1use core::fmt;
4
5#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7pub enum Error {
8 Overflow,
10 InvalidDate,
12 InvalidTime,
14 UtcUndefined,
16 LeapTableExpired,
18 Ut1Undefined,
20 Ut1TableExpired,
22 Parse,
24 BufferTooSmall,
26 Codec,
28 DstGap,
30 Unsupported,
32}
33
34impl fmt::Display for Error {
35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
36 match self {
37 Self::Overflow => f.write_str("nanosecond arithmetic overflow"),
38 Self::InvalidDate => f.write_str("invalid calendar date"),
39 Self::InvalidTime => f.write_str("invalid clock time"),
40 Self::UtcUndefined => f.write_str("UTC is not defined before 1960-01-01"),
41 Self::LeapTableExpired => {
42 f.write_str("UTC date is beyond the pinned leap-second table")
43 }
44 Self::Ut1Undefined => f.write_str("UT1 is not defined before 1972-01-01 in this crate"),
45 Self::Ut1TableExpired => f.write_str("UTC date is beyond the pinned DUT1 table"),
46 Self::Parse => f.write_str("timestamp parse error"),
47 Self::BufferTooSmall => f.write_str("output buffer too small"),
48 Self::Codec => f.write_str("time-code codec error"),
49 Self::DstGap => f.write_str("civil time does not exist (DST gap)"),
50 Self::Unsupported => f.write_str("unsupported in this crate feature set"),
51 }
52 }
53}
54
55#[cfg(feature = "std")]
56impl std::error::Error for Error {}
57
58pub type Result<T> = core::result::Result<T, Error>;