tempoch_core/period/
error.rs1use core::fmt;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum InvalidIntervalError {
11 StartAfterEnd,
13}
14
15impl fmt::Display for InvalidIntervalError {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 f.write_str("interval start must not be after end")
18 }
19}
20
21impl std::error::Error for InvalidIntervalError {}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum PeriodListError {
26 InvalidInterval { index: usize },
28 Unsorted { index: usize },
30 Overlapping { index: usize },
32}
33
34impl fmt::Display for PeriodListError {
35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
36 match self {
37 Self::InvalidInterval { index } => {
38 write!(f, "interval at index {index} has start > end")
39 }
40 Self::Unsorted { index } => {
41 write!(f, "interval at index {index} is not sorted by start time")
42 }
43 Self::Overlapping { index } => {
44 write!(f, "interval at index {index} overlaps its predecessor")
45 }
46 }
47 }
48}
49
50impl std::error::Error for PeriodListError {}