Struct cronchik::CronSchedule
source · pub struct CronSchedule { /* private fields */ }
Expand description
Cron schedule.
Size
184 bytes.
This is relatively big struct, which might be better suited to be allocated on heap.
So if you expect to move it a lot, prefer heap.
Alternatively you could store cron expression as String
and parse it each time.
Usage
use cronchik::CronSchedule;
let schedule = CronSchedule::parse_str("5 * * * *").unwrap();
assert_eq!(core::mem::size_of::<CronSchedule>(), 184);
let display = format!("{}", schedule);
assert_eq!(display, "5 * * * *");
Implementations§
source§impl CronSchedule
impl CronSchedule
sourcepub fn parse_str(text: &str) -> Result<Self, ParseError>
pub fn parse_str(text: &str) -> Result<Self, ParseError>
Parses cron expression from string.
sourcepub fn days_of_month(&self) -> &[DayOfMonth]
pub fn days_of_month(&self) -> &[DayOfMonth]
Returns ordered list of scheduled days in month to run at.
sourcepub fn days_of_week(&self) -> &[Day]
pub fn days_of_week(&self) -> &[Day]
Returns ordered list of scheduled days in week to run at.
sourcepub fn next_time_from(&self, time: OffsetDateTime) -> OffsetDateTime
pub fn next_time_from(&self, time: OffsetDateTime) -> OffsetDateTime
Returns next point if time, after time
, accordingly to the schedule.
Available with time
feature
sourcepub fn next_time_from_now(&self) -> OffsetDateTime
pub fn next_time_from_now(&self) -> OffsetDateTime
Returns next point if time, after current time in UTC timezone.
Available with time
feature
Trait Implementations§
source§impl Clone for CronSchedule
impl Clone for CronSchedule
source§fn clone(&self) -> CronSchedule
fn clone(&self) -> CronSchedule
Returns a copy of the value. Read more
1.0.0 · 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 CronSchedule
impl Debug for CronSchedule
source§impl<'de> Deserialize<'de> for CronSchedule
impl<'de> Deserialize<'de> for CronSchedule
source§fn deserialize<D: Deserializer<'de>>(des: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(des: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for CronSchedule
impl Display for CronSchedule
source§impl PartialEq<CronSchedule> for CronSchedule
impl PartialEq<CronSchedule> for CronSchedule
source§fn eq(&self, other: &CronSchedule) -> bool
fn eq(&self, other: &CronSchedule) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for CronSchedule
impl Serialize for CronSchedule
impl Eq for CronSchedule
impl StructuralEq for CronSchedule
impl StructuralPartialEq for CronSchedule
Auto Trait Implementations§
impl RefUnwindSafe for CronSchedule
impl Send for CronSchedule
impl Sync for CronSchedule
impl Unpin for CronSchedule
impl UnwindSafe for CronSchedule
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