Skip to main content

Job

Trait Job 

Source
pub trait Job: Send + Sync {
    // Required methods
    fn execute(&self);
    fn schedule(&self) -> Schedule;

    // Provided methods
    fn should_run(&self) -> bool { ... }
    fn allow_parallel_runs(&self) -> bool { ... }
    fn now(&self) -> DateTime<Utc> { ... }
}
Expand description

Job Trait

Implement this trait for any struct you want to run as a Job.

Required Methods§

Source

fn execute(&self)

Source

fn schedule(&self) -> Schedule

Define a schedule for your job

Provided Methods§

Source

fn should_run(&self) -> bool

Returns whether the job should run now or not

Source

fn allow_parallel_runs(&self) -> bool

If you want your Job to run again, while another instance of it is already running overwrite this The default behaviour is that while a job is running it will not be executed again.

Source

fn now(&self) -> DateTime<Utc>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§