| 1 |
use crate::error; |
| 2 |
|
| 3 |
#[derive(Clone, Debug)] |
| 4 |
#[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 5 |
pub(crate) enum Error { |
| 6 |
FailedNegateUnsignedDuration, |
| 7 |
RangeUnsignedDuration, |
| 8 |
} |
| 9 |
|
| 10 |
impl 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 |
|
| 18 |
impl error::IntoError for Error { |
| 19 |
fn into_error(self) -> error::Error { |
| 20 |
self.into() |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
impl 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 |
} |