pub struct CronSchedule { /* private fields */ }Expand description
A validated cron_restart pattern together with the zone it is read in.
The croner and chrono-tz types are private: a cron dialect is a Flockfile grammar promise, and pinning it to a dependency’s public types would make that dependency’s next major version a breaking change to shep’s own config surface (IR-11).
Implementations§
Source§impl CronSchedule
impl CronSchedule
Sourcepub fn parse(
pattern: &str,
timezone: Option<&str>,
) -> Result<Self, CronParseError>
pub fn parse( pattern: &str, timezone: Option<&str>, ) -> Result<Self, CronParseError>
Parses a cron_restart pattern and its optional cron_timezone.
§Errors
CronParseError::Pattern— croner rejected the pattern.CronParseError::Timezone— the name is not an IANA zone.
Sourcepub fn next_after(
&self,
after: DateTime<Utc>,
) -> Result<Option<DateTime<Utc>>, CronScheduleError>
pub fn next_after( &self, after: DateTime<Utc>, ) -> Result<Option<DateTime<Utc>>, CronScheduleError>
The first occurrence strictly after after, in UTC.
Returns None when the pattern has no further occurrence croner is
willing to search for — a pattern like 0 0 30 2 * (30 February) that
can never match.
A pattern that matches an hour repeated by a DST fall-back can return the same wall-clock occurrence twice across two successive calls — once for each pass through that hour. This is croner’s own standard local-time search semantics, not a defect this wrapper introduces or could suppress without also making the reverse case (a spring-forward hour that never occurs) harder to reason about.
§Errors
CronScheduleError::Search— croner failed the search for a reason other than exhaustion, carrying its own sentence.
§Panics
Panics if converting after into zone’s local calendar lands
outside the range chrono’s NaiveDateTime can represent — chrono
panics rather than erroring in that case, and croner has no fallible
entry point that avoids it (e.g. DateTime::<Utc>::MAX_UTC read in
Pacific/Kiritimati, UTC+14, which pushes the local instant past the
representable range). Unreachable from Utc::now(), which is the
only after this crate’s own callers pass; documented rather than
guarded because a guard would exist solely for an instant no caller
can construct without going out of their way to do it.
Trait Implementations§
Source§impl Clone for CronSchedule
impl Clone for CronSchedule
Source§fn clone(&self) -> CronSchedule
fn clone(&self) -> CronSchedule
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more