Skip to main content

validate_period_list

Function validate_period_list 

Source
pub fn validate_period_list<T: TimeInstant>(
    periods: &[Interval<T>],
) -> Result<(), PeriodListError>
Expand description

Validate that a period list is sorted by start time and non-overlapping.

Checks three invariants on every element:

  1. Each interval has start <= end.
  2. Intervals are sorted by start time (monotonically non-decreasing).
  3. Adjacent intervals do not overlap (previous end <= next start).

Returns Ok(()) if all invariants hold, or the first violation found.

ยงExamples

use tempoch::{validate_period_list, Interval, ModifiedJulianDate};

let sorted = vec![
    Interval::new(ModifiedJulianDate::new(0.0), ModifiedJulianDate::new(3.0)),
    Interval::new(ModifiedJulianDate::new(5.0), ModifiedJulianDate::new(8.0)),
];
assert!(validate_period_list(&sorted).is_ok());