automata/cron

UNIX 5-field cron stack: parse a cron string, validate it, normalise it into a fast-evaluation CronPlan, and ask whether a given ValidDateTime matches or what the next match is. This module is the user-facing facade; the typed phases live in the automata/cron/{ast,parser,validator,normalize,evaluator,iterator, next,builder} submodules.

Values

pub fn at(value value: Int) -> validator.Selector
pub fn between(
  from start: Int,
  to end: Int,
) -> validator.Selector
pub fn build(
  builder builder: builder.Builder,
) -> Result(validator.ValidCron, validator.ValidationError)
pub fn builder() -> builder.Builder
pub fn every(step step: Int) -> validator.Selector
pub fn every_between(
  from start: Int,
  to end: Int,
  step step: Int,
) -> validator.Selector
pub fn every_from(
  start start: Int,
  step step: Int,
) -> validator.Selector
pub fn item_exact(value value: Int) -> validator.Item

Build an Item matching a single value (for use inside one_of).

pub fn item_range(from start: Int, to end: Int) -> validator.Item

Build an Item matching every value in [from, to] inclusive.

pub fn item_step_any(step step: Int) -> validator.Item

Build an Item of the form */step (every step-th value across the field’s full range).

pub fn item_step_between(
  from start: Int,
  to end: Int,
  step step: Int,
) -> validator.Item

Build an Item of the form from-to/step.

pub fn item_step_from(
  start start: Int,
  step step: Int,
) -> validator.Item

Build an Item of the form start/step.

pub fn iterator_after(
  spec spec: validator.ValidCron,
  boundary boundary: ast.Boundary,
) -> iterator.CronIterator
pub fn iterator_after_plan(
  plan plan: normalize.CronPlan,
  boundary boundary: ast.Boundary,
) -> iterator.CronIterator

Plan-reuse counterpart to iterator_after/2.

pub fn matches(
  spec spec: validator.ValidCron,
  at at: ast.ValidDateTime,
) -> Bool
pub fn matches_plan(
  plan plan: normalize.CronPlan,
  at at: ast.ValidDateTime,
) -> Bool

Same as matches/2 but takes an already-normalized CronPlan, so callers that evaluate the same spec many times can pay the normalisation cost once.

pub fn next_after_plan(
  plan plan: normalize.CronPlan,
  after after: ast.ValidDateTime,
) -> option.Option(ast.ValidDateTime)

Plan-reuse counterpart to next_after/2.

pub fn normalize(
  spec spec: validator.ValidCron,
) -> normalize.CronPlan

Pre-compute the lookup tables evaluator/iterator/next need. Reuse the resulting CronPlan across calls if you evaluate the same spec many times — see the *_plan variants.

pub fn one_of(
  items items: List(validator.Item),
) -> validator.Selector
pub fn parse(
  input input: String,
) -> Result(ast.RawCron, parser.ParseError)

Parse a UNIX 5-field cron expression (minute hour day-of-month month day-of-week) into a RawCron AST. Returns a ParseError for syntactic problems such as wrong field count or empty fields. Range and alias validation is done separately by validate/1.

pub fn to_string(spec spec: validator.ValidCron) -> String

Render a ValidCron back to its canonical 5-field string form.

pub fn validate(
  raw raw: ast.RawCron,
) -> Result(validator.ValidCron, validator.ValidationError)

Validate a RawCron and return a ValidCron (opaque) when every field is in range and consistent. The returned value is the only shape the rest of the pipeline accepts.

pub fn with_day_of_month(
  builder: builder.Builder,
  day_of_month: validator.Selector,
) -> builder.Builder
pub fn with_day_of_week(
  builder: builder.Builder,
  day_of_week: validator.Selector,
) -> builder.Builder
pub fn with_minute(
  builder: builder.Builder,
  minute: validator.Selector,
) -> builder.Builder
pub fn with_month(
  builder: builder.Builder,
  month: validator.Selector,
) -> builder.Builder
Search Document