Debian Codegraph @

debian/rust-vendor/jiff/src/error/tz/timezone.rs

raw
1 use crate::error;
2
3 #[derive(Clone, Debug)]
4 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5 pub(crate) enum Error {
6 ConvertNonFixed {
7 kind: &'static str,
8 },
9 #[cfg(not(feature = "tz-system"))]
10 FailedSystem,
11 }
12
13 impl From<Error> for error::Error {
14 #[cold]
15 #[inline(never)]
16 fn from(err: Error) -> error::Error {
17 error::ErrorKind::TzTimeZone(err).into()
18 }
19 }
20
21 impl error::IntoError for Error {
22 fn into_error(self) -> error::Error {
23 self.into()
24 }
25 }
26
27 impl core::fmt::Display for Error {
28 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
29 use self::Error::*;
30
31 match *self {
32 ConvertNonFixed { kind } => write!(
33 f,
34 "cannot convert non-fixed {kind} time zone to offset \
35 without a timestamp or civil datetime",
36 ),
37 #[cfg(not(feature = "tz-system"))]
38 FailedSystem => f.write_str("failed to get system time zone"),
39 }
40 }
41 }