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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! # TimerTask — Wait-Then-Transition Processing Model
//!
//! Run with: `cargo run --example timer_task`
//!
//! Demonstrates [`TimerTask`] as a "pause, then continue" processing unit. The `CoolDown`
//! timer sleeps for a fixed [`Duration`] (the engine schedules a *single* `tokio::time::sleep`,
//! not a polling loop), then transitions to the processing step.
//!
//! Workflow shape:
//!
//! ```text
//! CoolDown ──(sleep 50ms)──► Process ──► Done
//! ```
//!
//! Contrast with [`PollTask`](cano::PollTask): a poll task re-evaluates a condition on every
//! wake-up, whereas a timer wakes exactly once. Reach for a `TimerTask` when you just need a
//! deliberate delay — a cool-down between phases, a debounce, or resuming after a known delay via
//! a monotonic [`Instant`](std::time::Instant) and [`TimerOutcome::Until`].
//!
//! To cap the wait, `config()` can return `TaskConfig::minimal().with_attempt_timeout(dur)`; the
//! engine enforces it and produces `CanoError::Timeout` if the timer hasn't fired in time.
//!
//! Note: a `TimerTask` is checkpointed like any single-task state, so a resumed run re-runs
//! `wait()` and the delay restarts from scratch after a crash.
use Duration;
use *;
// ---------------------------------------------------------------------------
// State enum
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Timer task — waits a fixed cool-down, then transitions
// ---------------------------------------------------------------------------
/// Waits a fixed duration before letting the workflow continue.
// ---------------------------------------------------------------------------
// Processing task — runs after the cool-down
// ---------------------------------------------------------------------------
/// Simple post-cool-down processor that transitions to the exit state.
;
// ---------------------------------------------------------------------------
// Entry point
// ---------------------------------------------------------------------------
async