use core::fmt;
use derive_more::IsVariant;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, IsVariant)]
pub enum Component {
Latitude,
Longitude,
Minutes,
Seconds,
}
impl fmt::Display for Component {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Latitude => f.write_str("latitude degrees"),
Self::Longitude => f.write_str("longitude degrees"),
Self::Minutes => f.write_str("minutes"),
Self::Seconds => f.write_str("seconds"),
}
}
}
#[derive(Debug, Clone, PartialEq, thiserror::Error, IsVariant)]
pub enum ParseError {
#[error("unexpected input at byte {position}, expected {expected}")]
Unexpected {
position: usize,
expected: &'static str,
},
#[error("{component} value {value} out of range")]
OutOfRange {
component: Component,
value: f64,
},
#[error("invalid number at byte {position}")]
InvalidNumber {
position: usize,
},
}