use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[must_use = "errors must be handled; use `?` or `match` to inspect the failure"]
#[non_exhaustive]
pub enum GnssTimeError {
Overflow,
InvalidInput(&'static str),
LeapSecondsRequired,
}
impl fmt::Display for GnssTimeError {
fn fmt(
&self,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
match self {
GnssTimeError::Overflow => f.write_str("arithmetic overflow in nanosecond computation"),
GnssTimeError::InvalidInput(msg) => {
write!(f, "invalid input: {msg}")
}
GnssTimeError::LeapSecondsRequired => {
f.write_str("leap-second data required for this conversion")
}
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for GnssTimeError {}
#[cfg(feature = "defmt")]
impl defmt::Format for GnssTimeError {
fn format(
&self,
f: defmt::Formatter,
) {
match self {
GnssTimeError::Overflow => {
defmt::write!(f, "arithmetic overflow in nanoseconds")
}
GnssTimeError::InvalidInput(msg) => {
defmt::write!(f, "invalid input: {}", msg)
}
GnssTimeError::LeapSecondsRequired => {
defmt::write!(f, "leap-second data required")
}
}
}
}