use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum InvalidIntervalError {
StartAfterEnd,
}
impl fmt::Display for InvalidIntervalError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("interval start must not be after end")
}
}
impl std::error::Error for InvalidIntervalError {}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PeriodListError {
InvalidInterval { index: usize },
Unsorted { index: usize },
Overlapping { index: usize },
}
impl fmt::Display for PeriodListError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidInterval { index } => {
write!(f, "interval at index {index} has start > end")
}
Self::Unsorted { index } => {
write!(f, "interval at index {index} is not sorted by start time")
}
Self::Overlapping { index } => {
write!(f, "interval at index {index} overlaps its predecessor")
}
}
}
}
impl std::error::Error for PeriodListError {}