Skip to main content

jiff/error/
duration.rs

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::FailedNegateUnsignedDuration =>
                Error::FailedNegateUnsignedDuration,
            Self::RangeUnsignedDuration => Error::RangeUnsignedDuration,
        }
    }
}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::write_str(f,
            match self {
                Error::FailedNegateUnsignedDuration =>
                    "FailedNegateUnsignedDuration",
                Error::RangeUnsignedDuration => "RangeUnsignedDuration",
            })
    }
}Debug)]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5pub(crate) enum Error {
6    FailedNegateUnsignedDuration,
7    RangeUnsignedDuration,
8}
9
10impl From<Error> for error::Error {
11    #[cold]
12    #[inline(never)]
13    fn from(err: Error) -> error::Error {
14        error::ErrorKind::Duration(err).into()
15    }
16}
17
18impl error::IntoError for Error {
19    fn into_error(self) -> error::Error {
20        self.into()
21    }
22}
23
24impl core::fmt::Display for Error {
25    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
26        use self::Error::*;
27
28        match *self {
29            FailedNegateUnsignedDuration => {
30                f.write_str("failed to negate unsigned duration")
31            }
32            RangeUnsignedDuration => {
33                f.write_str("unsigned duration exceeds Jiff's limits")
34            }
35        }
36    }
37}