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
21#[cfg(feature = "std")]
22impl std::error::Error for InvalidIntervalError {}
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26pub enum PeriodListError {
27 InvalidInterval { index: usize },
29 Unsorted { index: usize },
31 Overlapping { index: usize },
33}
34
35impl fmt::Display for PeriodListError {
36 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 match self {
38 Self::InvalidInterval { index } => {
39 write!(f, "interval at index {index} has start > end")
40 }
41 Self::Unsorted { index } => {
42 write!(f, "interval at index {index} is not sorted by start time")
43 }
44 Self::Overlapping { index } => {
45 write!(f, "interval at index {index} overlaps its predecessor")
46 }
47 }
48 }
49}
50
51#[cfg(feature = "std")]
52impl std::error::Error for PeriodListError {}