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
//! # skedge
//!
//! `skedge` is a single-process job scheduler.
//! To use the optional CFFI, enable the "ffi" feature.
//!
//! Define a work function:
//! ```rust
//! fn job() {
//! println!("Hello, it's {}!", jiff::Zoned::now());
//! }
//! ```
//! You can use up to six arguments:
//! ```rust
//! fn greet(name: &str) {
//! println!("Hello, {}!", name);
//! }
//! ```
//! Instantiate a `Scheduler` and schedule jobs:
//! ```rust
//! # use skedge::{Scheduler, every, every_single};
//! # use jiff::{ToSpan, Zoned};
//! # use std::time::Duration;
//! # use std::thread::sleep;
//! # fn job() {
//! # println!("Hello, it's {}!", Zoned::now());
//! # }
//! # fn greet(name: &str) {
//! # println!("Hello, {}!", name);
//! # }
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut schedule = Scheduler::new();
//!
//! every(10).seconds()?.run(&mut schedule, job)?;
//! every(10).minutes()?.run(&mut schedule, job)?;
//! every_single().hour()?.run(&mut schedule, job)?;
//! every_single().day()?.at("10:30")?.run(&mut schedule, job)?;
//! every(5).to(10)?.minutes()?.run(&mut schedule, job)?;
//! every_single().monday()?.run(&mut schedule, job)?;
//! every_single().wednesday()?.at("13:15")?.run(&mut schedule, job)?;
//! every_single().minute()?.at(":17")?.run(&mut schedule, job)?;
//! every(2)
//! .to(8)?
//! .seconds()?
//! .until(Zoned::now().checked_add(30.seconds())?)?
//! .run_one_arg(&mut schedule, greet, "Cool Person")?;
//! # Ok(())
//! # }
//! ```
//! Note that you must use the appropriate `run_x_args()` method for job functions taking multiple arguments.
//! In your main loop, you can use `Scheduler::run_pending()` to fire all scheduled jobs at the proper time:
//! ```no_run
//! # use skedge::Scheduler;
//! # let mut schedule = Scheduler::new();
//! loop {
//! if let Err(e) = schedule.run_pending() {
//! eprintln!("Error: {e}");
//! }
//! std::thread::sleep(std::time::Duration::from_secs(1));
//! }
//! ```
use ;
pub use *;
pub use ;
pub use Scheduler;
use ;
pub use *;