time/error/
indeterminate_offset.rs

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