CronUtil

Struct CronUtil 

Source
pub struct CronUtil;

Implementations§

Source§

impl CronUtil

Source

pub fn parse(expression: &str) -> Result<CronExpression, CronError>

解析 cron 表达式为结构体 Parse cron expression into a struct

§参数
§Parameters
  • expression - cron 表达式,如 “0 0 * * *”
  • expression - cron expression, e.g. “0 0 * * *”
§示例
§Example
let cron = CronUtil::parse("0 0 * * *").unwrap();
Source

pub fn validate(expression: &str) -> bool

验证 cron 表达式是否有效 Validate if a cron expression is valid

§参数
§Parameters
  • expression - cron 表达式,如 “0 0 * * *”
  • expression - cron expression, e.g. “0 0 * * *”
§示例
§Example
if CronUtil::validate("0 0 * * *") {
    println!("Valid cron expression");
}
Source

pub fn next_execution(expression: &str) -> Result<DateTime<Local>, CronError>

从当前时间计算下一次执行时间 Calculate next execution time from current time

§参数
§Parameters
  • expression - cron 表达式
  • expression - cron expression
§示例
§Example
let next = CronUtil::next_execution("0 0 * * *").unwrap();
println!("Next execution time: {}", next);
Source

pub fn next_execution_from( expression: &str, from: DateTime<Local>, ) -> Result<DateTime<Local>, CronError>

从指定时间计算下一次执行时间 Calculate next execution time from a specific time

§参数
§Parameters
  • expression - cron 表达式
  • expression - cron expression
  • from - 起始时间
  • from - start time
Source

pub fn describe(expression: &str) -> Result<String, CronError>

生成 cron 表达式的人类可读描述 Generate human-readable description of a cron expression

§参数
§Parameters
  • expression - cron 表达式
  • expression - cron expression
§示例
§Example
let desc = CronUtil::describe("0 0 * * *").unwrap();
println!("{}", desc); // "Every day at 00:00"
Source

pub fn count_executions_between( expression: &str, start: DateTime<Local>, end: DateTime<Local>, ) -> Result<u32, CronError>

计算两个日期之间有多少次 cron 触发 Count number of cron executions between two dates

§参数
§Parameters
  • expression - cron 表达式
  • expression - cron expression
  • start - 开始时间
  • start - start time
  • end - 结束时间
  • end - end time
Source

pub fn next_n_executions( expression: &str, count: usize, ) -> Result<Vec<DateTime<Local>>, CronError>

获取未来 n 次执行时间 Get next n execution times

§参数
§Parameters
  • expression - cron 表达式
  • expression - cron expression
  • count - 需要获取的次数
  • count - number of times to get
Source

pub fn matches( expression: &str, date_time: DateTime<Local>, ) -> Result<bool, CronError>

根据 cron 表达式判断某个时间点是否会触发 Check if a specific time matches a cron expression

§参数
§Parameters
  • expression - cron 表达式
  • expression - cron expression
  • date_time - 待检查的时间点
  • date_time - time to check
Source

pub fn parse_alias(alias: &str) -> Result<String, CronError>

解析常用的 cron 表达式别名 Parse common cron expression aliases

§参数
§Parameters
  • alias - cron 表达式别名,如 “@daily”, “@hourly”
  • alias - cron expression alias, e.g. “@daily”, “@hourly”
Source

pub fn generate_cron( month: i32, week_day: i32, day: i32, hour: i32, minute: i32, ) -> String

根据给定的月、周、日、时、分生成 cron 表达式 Generate cron expression from given month, week day, day, hour and minute

§参数
§Parameters
  • month - 月份,1-12,0 表示所有月份
  • month - Month, 1-12, 0 means all months
  • week_day - 星期几,0-7(0 和 7 都表示星期日),-1 表示所有星期
  • week_day - Day of week, 0-7 (0 and 7 both represent Sunday), -1 means all days
  • day - 日期,1-31,0 表示所有日期
  • day - Day of month, 1-31, 0 means all days
  • hour - 小时,0-23,-1 表示所有小时
  • hour - Hour, 0-23, -1 means all hours
  • minute - 分钟,0-59,-1 表示所有分钟
  • minute - Minute, 0-59, -1 means all minutes
§返回
§Returns
  • String - 生成的 cron 表达式
  • String - Generated cron expression

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
Source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

Source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
Source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T, Dst> ConvAsUtil<Dst> for T

Source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
Source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
Source§

impl<T> ConvUtil for T

Source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
Source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
Source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
Source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
Source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<Src> TryFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

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

Source§

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<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

Source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
Source§

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

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Src> ValueFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
Source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

Source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.