pub struct CrontabTimer {
pub minutes: Vec<CrontabValue>,
pub hours: Vec<CrontabValue>,
pub days: Vec<CrontabValue>,
pub months: Vec<CrontabValue>,
pub dows: Vec<CrontabValue>,
}Expand description
A crontab timer is a set of crontab values for each field (minutes, hours, days, months, days of week)
Fields§
§minutes: Vec<CrontabValue>§hours: Vec<CrontabValue>§days: Vec<CrontabValue>§months: Vec<CrontabValue>§dows: Vec<CrontabValue>Days of week
Implementations§
Source§impl CrontabTimer
impl CrontabTimer
pub fn minutes(&self) -> &Vec<CrontabValue>
pub fn hours(&self) -> &Vec<CrontabValue>
pub fn days(&self) -> &Vec<CrontabValue>
pub fn months(&self) -> &Vec<CrontabValue>
Sourcepub fn dows(&self) -> &Vec<CrontabValue>
pub fn dows(&self) -> &Vec<CrontabValue>
Days of week
Source§impl CrontabTimer
impl CrontabTimer
Sourcepub fn every_minute() -> CrontabTimer
pub fn every_minute() -> CrontabTimer
Run every minute.
Sourcepub fn every_n_minutes(step: u32) -> Result<CrontabTimer, CrontabTimerError>
pub fn every_n_minutes(step: u32) -> Result<CrontabTimer, CrontabTimerError>
Run every step minutes.
Sourcepub fn hourly_at(minute: u32) -> Result<CrontabTimer, CrontabTimerError>
pub fn hourly_at(minute: u32) -> Result<CrontabTimer, CrontabTimerError>
Run once per hour at the given minute.
Sourcepub fn daily_at(
hour: u32,
minute: u32,
) -> Result<CrontabTimer, CrontabTimerError>
pub fn daily_at( hour: u32, minute: u32, ) -> Result<CrontabTimer, CrontabTimerError>
Run once per day at the given UTC hour and minute.
Sourcepub fn weekly_on(
weekday: Weekday,
hour: u32,
minute: u32,
) -> Result<CrontabTimer, CrontabTimerError>
pub fn weekly_on( weekday: Weekday, hour: u32, minute: u32, ) -> Result<CrontabTimer, CrontabTimerError>
Run once per week on the given weekday, UTC hour and minute.
Sourcepub fn monthly_on(
day: u32,
hour: u32,
minute: u32,
) -> Result<CrontabTimer, CrontabTimerError>
pub fn monthly_on( day: u32, hour: u32, minute: u32, ) -> Result<CrontabTimer, CrontabTimerError>
Run once per month on the given day, UTC hour and minute.
Sourcepub fn yearly_on(
month: u32,
day: u32,
hour: u32,
minute: u32,
) -> Result<CrontabTimer, CrontabTimerError>
pub fn yearly_on( month: u32, day: u32, hour: u32, minute: u32, ) -> Result<CrontabTimer, CrontabTimerError>
Run once per year on the given month, day, UTC hour and minute.
Sourcepub fn should_run_at(&self, at: &NaiveDateTime) -> bool
pub fn should_run_at(&self, at: &NaiveDateTime) -> bool
Check if the timer should run at specifed date
use graphile_worker_crontab_types::{CrontabValue, CrontabTimer};
let crontab_timer = CrontabTimer {
minutes: vec![CrontabValue::Number(30)],
hours: vec![CrontabValue::Range(8, 10)],
days: vec![CrontabValue::Step(4)],
..Default::default()
};
assert!(crontab_timer.should_run_at(&"2012-12-17T08:30:12".parse().unwrap()));
assert!(crontab_timer.should_run_at(&"2015-02-05T09:30:00".parse().unwrap()));
assert!(crontab_timer.should_run_at(&"1998-10-13T10:30:59".parse().unwrap()));
assert!(!crontab_timer.should_run_at(&"2012-12-17T11:30:59".parse().unwrap()));
assert!(!crontab_timer.should_run_at(&"2015-02-05T09:31:00".parse().unwrap()));Trait Implementations§
Source§impl Clone for CrontabTimer
impl Clone for CrontabTimer
Source§fn clone(&self) -> CrontabTimer
fn clone(&self) -> CrontabTimer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CrontabTimer
impl Debug for CrontabTimer
Source§impl Default for CrontabTimer
impl Default for CrontabTimer
Source§fn default() -> CrontabTimer
fn default() -> CrontabTimer
Returns the “default value” for a type. Read more
Source§impl PartialEq for CrontabTimer
impl PartialEq for CrontabTimer
Source§fn eq(&self, other: &CrontabTimer) -> bool
fn eq(&self, other: &CrontabTimer) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for CrontabTimer
impl StructuralPartialEq for CrontabTimer
Auto Trait Implementations§
impl Freeze for CrontabTimer
impl RefUnwindSafe for CrontabTimer
impl Send for CrontabTimer
impl Sync for CrontabTimer
impl Unpin for CrontabTimer
impl UnsafeUnpin for CrontabTimer
impl UnwindSafe for CrontabTimer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more