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
//! Uhrwerk is a simple scheduler,
//! forked from [clokwerk](https://crates.io/crates/clokwerk), which itself is inspired
//! by Python's [Schedule](https://schedule.readthedocs.io/en/stable/)
//! and Ruby's [clockwork](https://github.com/Rykian/clockwork).
//! It uses a similar DSL for scheduling, rather than parsing cron strings.
//!
//! Uhrwerk supports both synchronous and asynchronous tasks.
//!
//! # Usage
//!
//! ```rust
//! // Import week days and WeekDay
//! use uhrwerk::Interval::*;
//! // Scheduler and trait for .seconds(), .minutes(), etc.
//! use uhrwerk::{Job as _, Scheduler, TimeUnits as _};
//! # use std::thread;
//! # use std::time::Duration;
//! # use time::UtcOffset;
//!
//! // Create a new scheduler
//! let mut scheduler = Scheduler::new();
//! // or a scheduler with a given timezone
//! let mut scheduler = Scheduler::new_with_utc_offset(UtcOffset::UTC);
//! // Add some tasks to it
//! scheduler
//! .every(10.minutes())
//! .plus(30.seconds())
//! .run(|| println!("Periodic task"));
//! scheduler
//! .every(1.day())
//! .at("3:20 pm")
//! .run(|| println!("Daily task"));
//! scheduler
//! .every(Tuesday)
//! .at("14:20:17")
//! .and_every(Thursday)
//! .at("15:00")
//! .run(|| println!("Biweekly task"));
//!
//! // Manually run the scheduler in an event loop
//! for _ in 1 .. 10 {
//! scheduler.run_pending();
//! thread::sleep(Duration::from_millis(10));
//! }
//! // Or run it in a background thread
//! let thread_handle = scheduler.watch_thread(Duration::from_millis(100));
//! // The scheduler stops when `thread_handle` is dropped, or `stop` is called
//! thread_handle.stop();
//! ```
//!
//! By default, dates and times are relative to the local timezone, but the scheduler
//! can be made to use a different timezone using [`Scheduler::new_with_utc_offset`].
//!
//! For more details, see [`Scheduler`] or its async counterpart, [`AsyncScheduler`].
//!
//! # Caveats
//!
//! Some combinations of times or intervals are permissible, but make little sense, e.g.
//! `every(10.seconds()).at("16:00")`, which would next run at the next 4 PM after the
//! next multiple of 10 seconds.
//!
//! # Trivia
//!
//! _Uhrwerk_ is the German word for _clockwork_.
pub use crateAsyncJob;
pub use crateAsyncScheduler;
pub use crate::;