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

source

pub fn parse_str(text: &str) -> Result<Self, ParseError>

Parses cron expression from string.

source

pub fn days_of_month(&self) -> &[DayOfMonth]

Returns ordered list of scheduled days in month to run at.

source

pub fn minutes(&self) -> &[Minute]

Returns ordered list of scheduled minutes to run at.

source

pub fn hours(&self) -> &[Hour]

Returns ordered list of scheduled hours to run at.

source

pub fn days_of_week(&self) -> &[Day]

Returns ordered list of scheduled days in week to run at.

source

pub fn months(&self) -> &[Month]

Returns ordered list of scheduled months to run at.

source

pub fn next_time_from(&self, time: OffsetDateTime) -> OffsetDateTime

Returns next point if time, after time, accordingly to the schedule.

Available with time feature

source

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

source§

fn clone(&self) -> CronSchedule

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CronSchedule

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for CronSchedule

source§

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

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<CronSchedule> for CronSchedule

source§

fn eq(&self, other: &CronSchedule) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for CronSchedule

source§

fn serialize<SER: Serializer>(&self, ser: SER) -> Result<SER::Ok, SER::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for CronSchedule

source§

impl StructuralEq for CronSchedule

source§

impl StructuralPartialEq for CronSchedule

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,