1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
//! # cronjob
//!
//! The `cronjob` library lets you create cronjobs for your methods.
//!
//! ## Getting started
//!
//! ``` no_run
//! extern crate cronjob;
//! use cronjob::CronJob;
//!
//! fn main() {
//! // Create the `CronJob` object.
//! let mut cron = CronJob::new("Test Cron", on_cron);
//! // Start the cronjob.
//! cron.start_job();
//! }
//!
//! // Our cronjob handler.
//! fn on_cron(name: &str) {
//! println!("{}: It's time!", name);
//! }
//! ```
//!
//! ## schedule
//! The `cronjob` allows to optionally add schedule parameters.
//!
//! ``` no_run
//! extern crate cronjob;
//! use cronjob::CronJob;
//!
//! fn main() {
//! // Create the `CronJob` object.
//! let mut cron = CronJob::new("Test Cron", on_cron);
//! // Set seconds.
//! cron.seconds("0");
//! // Set minutes.
//! cron.minutes(0);
//! // Start the cronjob.
//! cron.start_job();
//! }
//!
//! // Our cronjob handler.
//! fn on_cron(name: &str) {
//! println!("{}: It's time!", name);
//! }
//! ```
//!
//! ## Threaded
//! ``` no_run
//! extern crate cronjob;
//! use cronjob::CronJob;
//!
//! fn main() {
//! // Create the `CronJob` object.
//! let mut cron = CronJob::new("Test Cron Threaded", on_cron);
//! // Set seconds.
//! cron.seconds("0");
//! // Set minutes.
//! cron.minutes(0);
//! // Start the cronjob.
//! CronJob::start_job_threaded(cron);
//! }
//!
//! // Our cronjob handler.
//! fn on_cron(name: &str) {
//! println!("{}: It's time!", name);
//! }
//! ```
extern crate cron;
extern crate chrono;
pub use cronjob::CronJob;
use command::Command;
mod cronjob;
mod command;
/// Implementation of `Command` for your methods to be used by the `CronJob` object
impl<T: Sync + Send + 'static + FnMut(&str)> Command for T {
fn execute(&mut self, name: &str) {
self(name);
}
}