//! Based on code from use cron_job::{CronJob, Job}; fn main() { // Create HelloJob let hello_job = HelloJob { name: "John".into(), }; // Create CronJob let mut cron = CronJob::default(); // Run function every second cron.new_job("* * * * * *", run_every_second); // Say hello every second cron.new_job("* * * * * *", hello_job); // Start jobs cron.start().expect("Failed to start jobs"); } // The function to be executed every second. fn run_every_second() { println!("1 second"); } // The job to be executed struct HelloJob { name: String, } // Very important, implement the Job trait and its functions. impl Job for HelloJob { fn run(&mut self) { println!("Hello, {}!", self.name); } }