Debian Codegraph @

third_party/rust/time/src/error/indeterminate_offset.rs

raw
1 //! Indeterminate offset
2
3 use core::fmt;
4
5 use crate::error;
6
7 /// The system's UTC offset could not be determined at the given datetime.
8 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9 pub struct IndeterminateOffset;
10
11 impl fmt::Display for IndeterminateOffset {
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 f.write_str("The system's UTC offset could not be determined")
14 }
15 }
16
17 #[cfg(feature = "std")]
18 impl std::error::Error for IndeterminateOffset {}
19
20 impl From<IndeterminateOffset> for crate::Error {
21 fn from(err: IndeterminateOffset) -> Self {
22 Self::IndeterminateOffset(err)
23 }
24 }
25
26 impl TryFrom<crate::Error> for IndeterminateOffset {
27 type Error = error::DifferentVariant;
28
29 fn try_from(err: crate::Error) -> Result<Self, Self::Error> {
30 match err {
31 crate::Error::IndeterminateOffset(err) => Ok(err),
32 _ => Err(error::DifferentVariant),
33 }
34 }
35 }