pub struct Cron { /* private fields */ }Expand description
Fluent builder for a 5-field cron expression with optional time-of-day filters and a timezone.
Implementations§
Source§impl Cron
impl Cron
Sourcepub fn expression(&self) -> &str
pub fn expression(&self) -> &str
The current cron expression.
Sourcepub const fn repeat_seconds(&self) -> u32
pub const fn repeat_seconds(&self) -> u32
The sub-minute repeat interval in seconds, or 0 if none is configured.
Set by Cron::every_second and its siblings.
Sourcepub fn filters_pass(&self) -> bool
pub fn filters_pass(&self) -> bool
Evaluate all registered filters: returns true if every when filter returns true and no skip filter returns true.
Sourcepub fn when<F: Fn() -> bool + Send + Sync + 'static>(
&mut self,
filter: F,
) -> &mut Self
pub fn when<F: Fn() -> bool + Send + Sync + 'static>( &mut self, filter: F, ) -> &mut Self
Register a filter; the event runs only when every when filter returns true.
Sourcepub fn skip<F: Fn() -> bool + Send + Sync + 'static>(
&mut self,
filter: F,
) -> &mut Self
pub fn skip<F: Fn() -> bool + Send + Sync + 'static>( &mut self, filter: F, ) -> &mut Self
Register a reject filter; the event is skipped whenever any skip filter returns true.
Sourcepub fn between(&mut self, start_time: &str, end_time: &str) -> &mut Self
pub fn between(&mut self, start_time: &str, end_time: &str) -> &mut Self
Schedule the event to run only between two times of day (e.g. "09:00", "17:00").
Times are parsed as HH:MM[:SS]. Windows that cross midnight (end < start)
are handled by rolling one side to the adjacent day.
Sourcepub fn unless_between(&mut self, start_time: &str, end_time: &str) -> &mut Self
pub fn unless_between(&mut self, start_time: &str, end_time: &str) -> &mut Self
Schedule the event to run except between two times of day.
The inverse of Cron::between.
Sourcepub fn every_second(&mut self) -> &mut Self
pub fn every_second(&mut self) -> &mut Self
Schedule the event to run every second.
Sourcepub fn every_two_seconds(&mut self) -> &mut Self
pub fn every_two_seconds(&mut self) -> &mut Self
Schedule the event to run every two seconds.
Sourcepub fn every_five_seconds(&mut self) -> &mut Self
pub fn every_five_seconds(&mut self) -> &mut Self
Schedule the event to run every five seconds.
Sourcepub fn every_ten_seconds(&mut self) -> &mut Self
pub fn every_ten_seconds(&mut self) -> &mut Self
Schedule the event to run every ten seconds.
Sourcepub fn every_fifteen_seconds(&mut self) -> &mut Self
pub fn every_fifteen_seconds(&mut self) -> &mut Self
Schedule the event to run every fifteen seconds.
Sourcepub fn every_twenty_seconds(&mut self) -> &mut Self
pub fn every_twenty_seconds(&mut self) -> &mut Self
Schedule the event to run every twenty seconds.
Sourcepub fn every_thirty_seconds(&mut self) -> &mut Self
pub fn every_thirty_seconds(&mut self) -> &mut Self
Schedule the event to run every thirty seconds.
Sourcepub fn every_minute(&mut self) -> &mut Self
pub fn every_minute(&mut self) -> &mut Self
Schedule the event to run every minute.
Sourcepub fn every_two_minutes(&mut self) -> &mut Self
pub fn every_two_minutes(&mut self) -> &mut Self
Schedule the event to run every two minutes.
Sourcepub fn every_three_minutes(&mut self) -> &mut Self
pub fn every_three_minutes(&mut self) -> &mut Self
Schedule the event to run every three minutes.
Sourcepub fn every_four_minutes(&mut self) -> &mut Self
pub fn every_four_minutes(&mut self) -> &mut Self
Schedule the event to run every four minutes.
Sourcepub fn every_five_minutes(&mut self) -> &mut Self
pub fn every_five_minutes(&mut self) -> &mut Self
Schedule the event to run every five minutes.
Sourcepub fn every_ten_minutes(&mut self) -> &mut Self
pub fn every_ten_minutes(&mut self) -> &mut Self
Schedule the event to run every ten minutes.
Sourcepub fn every_fifteen_minutes(&mut self) -> &mut Self
pub fn every_fifteen_minutes(&mut self) -> &mut Self
Schedule the event to run every fifteen minutes.
Sourcepub fn every_thirty_minutes(&mut self) -> &mut Self
pub fn every_thirty_minutes(&mut self) -> &mut Self
Schedule the event to run every thirty minutes.
Sourcepub fn hourly_at(&mut self, offset: impl IntoCronValue) -> &mut Self
pub fn hourly_at(&mut self, offset: impl IntoCronValue) -> &mut Self
Schedule the event to run hourly at a given offset (a minute, list, or pattern) in the hour.
Sourcepub fn every_odd_hour(&mut self) -> &mut Self
pub fn every_odd_hour(&mut self) -> &mut Self
Schedule the event to run every odd hour.
Sourcepub fn every_odd_hour_at(&mut self, offset: impl IntoCronValue) -> &mut Self
pub fn every_odd_hour_at(&mut self, offset: impl IntoCronValue) -> &mut Self
Schedule the event to run every odd hour at a given minute offset.
Sourcepub fn every_two_hours(&mut self) -> &mut Self
pub fn every_two_hours(&mut self) -> &mut Self
Schedule the event to run every two hours.
Sourcepub fn every_two_hours_at(&mut self, offset: impl IntoCronValue) -> &mut Self
pub fn every_two_hours_at(&mut self, offset: impl IntoCronValue) -> &mut Self
Schedule the event to run every two hours at a given minute offset.
Sourcepub fn every_three_hours(&mut self) -> &mut Self
pub fn every_three_hours(&mut self) -> &mut Self
Schedule the event to run every three hours.
Sourcepub fn every_three_hours_at(&mut self, offset: impl IntoCronValue) -> &mut Self
pub fn every_three_hours_at(&mut self, offset: impl IntoCronValue) -> &mut Self
Schedule the event to run every three hours at a given minute offset.
Sourcepub fn every_four_hours(&mut self) -> &mut Self
pub fn every_four_hours(&mut self) -> &mut Self
Schedule the event to run every four hours.
Sourcepub fn every_four_hours_at(&mut self, offset: impl IntoCronValue) -> &mut Self
pub fn every_four_hours_at(&mut self, offset: impl IntoCronValue) -> &mut Self
Schedule the event to run every four hours at a given minute offset.
Sourcepub fn every_six_hours(&mut self) -> &mut Self
pub fn every_six_hours(&mut self) -> &mut Self
Schedule the event to run every six hours.
Sourcepub fn every_six_hours_at(&mut self, offset: impl IntoCronValue) -> &mut Self
pub fn every_six_hours_at(&mut self, offset: impl IntoCronValue) -> &mut Self
Schedule the event to run every six hours at a given minute offset.
Sourcepub fn at(&mut self, time: &str) -> &mut Self
pub fn at(&mut self, time: &str) -> &mut Self
Alias for Cron::daily_at.
Sourcepub fn daily_at(&mut self, time: &str) -> &mut Self
pub fn daily_at(&mut self, time: &str) -> &mut Self
Schedule the event to run daily at a given time, formatted as HH:MM (e.g. "10:00", "19:30").
Seconds, if provided, are ignored.
Sourcepub fn twice_daily(&mut self, first: u32, second: u32) -> &mut Self
pub fn twice_daily(&mut self, first: u32, second: u32) -> &mut Self
Schedule the event to run twice daily at the given hours (minute 0).
Sourcepub fn twice_daily_at(
&mut self,
first: u32,
second: u32,
offset: u32,
) -> &mut Self
pub fn twice_daily_at( &mut self, first: u32, second: u32, offset: u32, ) -> &mut Self
Schedule the event to run twice daily at the given hours and minute offset.
Sourcepub fn weekdays(&mut self) -> &mut Self
pub fn weekdays(&mut self) -> &mut Self
Schedule the event to run only on weekdays (Monday–Friday).
Sourcepub fn weekends(&mut self) -> &mut Self
pub fn weekends(&mut self) -> &mut Self
Schedule the event to run only on weekends (Saturday and Sunday).
Sourcepub fn wednesdays(&mut self) -> &mut Self
pub fn wednesdays(&mut self) -> &mut Self
Schedule the event to run only on Wednesdays.
Sourcepub fn weekly_on(
&mut self,
day_of_week: impl IntoCronValue,
time: &str,
) -> &mut Self
pub fn weekly_on( &mut self, day_of_week: impl IntoCronValue, time: &str, ) -> &mut Self
Schedule the event to run weekly on a given day and time.
Sourcepub fn monthly(&mut self) -> &mut Self
pub fn monthly(&mut self) -> &mut Self
Schedule the event to run monthly (first of the month at midnight).
Sourcepub fn monthly_on(&mut self, day_of_month: u32, time: &str) -> &mut Self
pub fn monthly_on(&mut self, day_of_month: u32, time: &str) -> &mut Self
Schedule the event to run monthly on a given day and time.
Sourcepub fn twice_monthly(&mut self, first: u32, second: u32) -> &mut Self
pub fn twice_monthly(&mut self, first: u32, second: u32) -> &mut Self
Schedule the event to run twice monthly on the given days at midnight.
Sourcepub fn twice_monthly_at(
&mut self,
first: u32,
second: u32,
time: &str,
) -> &mut Self
pub fn twice_monthly_at( &mut self, first: u32, second: u32, time: &str, ) -> &mut Self
Schedule the event to run twice monthly on the given days at a given time.
Sourcepub fn last_day_of_month(&mut self) -> &mut Self
pub fn last_day_of_month(&mut self) -> &mut Self
Schedule the event to run on the last day of the month at midnight.
The last-day value is resolved against current time at build, so the resulting expression is anchored to the day-count of the current month (28–31).
Sourcepub fn last_day_of_month_at(&mut self, time: &str) -> &mut Self
pub fn last_day_of_month_at(&mut self, time: &str) -> &mut Self
Schedule the event to run on the last day of the month at a given time.
See Cron::last_day_of_month for the caveat on when the day-of-month is resolved.
Sourcepub fn days_of_month(&mut self, days: &[u32]) -> &mut Self
pub fn days_of_month(&mut self, days: &[u32]) -> &mut Self
Schedule the event to run on specific days of the month at midnight.
Sourcepub fn quarterly(&mut self) -> &mut Self
pub fn quarterly(&mut self) -> &mut Self
Schedule the event to run quarterly (first day of Jan, Apr, Jul, Oct at midnight).
Sourcepub fn quarterly_on(&mut self, day_of_quarter: u32, time: &str) -> &mut Self
pub fn quarterly_on(&mut self, day_of_quarter: u32, time: &str) -> &mut Self
Schedule the event to run quarterly on a given day-of-quarter and time.
Sourcepub fn yearly(&mut self) -> &mut Self
pub fn yearly(&mut self) -> &mut Self
Schedule the event to run yearly (January 1st at midnight).
Sourcepub fn yearly_on(
&mut self,
month: u32,
day_of_month: impl IntoCronValue,
time: &str,
) -> &mut Self
pub fn yearly_on( &mut self, month: u32, day_of_month: impl IntoCronValue, time: &str, ) -> &mut Self
Schedule the event to run yearly on a given month, day, and time.
Sourcepub fn days(&mut self, days: impl IntoCronValue) -> &mut Self
pub fn days(&mut self, days: impl IntoCronValue) -> &mut Self
Set the days of the week the event should run on (the 5th cron field).
Sourcepub const fn timezone(&mut self, timezone: Tz) -> &mut Self
pub const fn timezone(&mut self, timezone: Tz) -> &mut Self
Set the timezone the time-based filters (Cron::between,
Cron::unless_between, Cron::last_day_of_month) are evaluated in.