clockwork_cron/
specifier.rs

1use crate::ordinal::*;
2
3#[derive(Debug, PartialEq)]
4pub enum Specifier {
5    All,
6    Point(Ordinal),
7    Range(Ordinal, Ordinal),
8    NamedRange(String, String),
9}
10
11// Separating out a root specifier allows for a higher tiered specifier, allowing us to achieve
12// periods with base values that are more advanced than an ordinal:
13// - all: '*/2'
14// - range: '10-2/2'
15// - named range: 'Mon-Thurs/2'
16//
17// Without this separation we would end up with invalid combinations such as 'Mon/2'
18#[derive(Debug, PartialEq)]
19pub enum RootSpecifier {
20    Specifier(Specifier),
21    Period(Specifier, u32),
22    NamedPoint(String),
23}
24
25impl From<Specifier> for RootSpecifier {
26    fn from(specifier: Specifier) -> Self {
27        Self::Specifier(specifier)
28    }
29}