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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
//! THE TERMINAL FATES: the three ways a delivery ends without ever reaching a station.
//!
//! A [`Station`](super::Station) is what a CONSUMER says about an item it was handed. A [`Fate`] is
//! what the FRAMEWORK says about a delivery no consumer will ever be handed: it was shed at a full
//! edge, its retries ran out, or the budget it was waiting under elapsed. Neither vocabulary can
//! stand in for the other — a shed item was never processed, so calling it
//! [`Skipped`](super::Station::Skipped) would claim an operator refused it, and calling it
//! [`Failed`](super::Station::Failed) would hold a window for work that is never coming back.
//!
//! # ONE vocabulary, two streams
//!
//! A fate is spoken on the delivery's own oneshot — which is what credits the sender's window and
//! keeps a terminal from surfacing as an anonymous *the consumer hung up* — and it is spoken again
//! to the [`LifecycleTap`](super::LifecycleTap)s, as an [`Observation`]. The two are the same words
//! because they are built from the same value: [`Fate::erase`] is the one crossing, and every
//! terminal the oneshot can speak is therefore a terminal the observation stream can see.
//!
//! # The extra message, and why it is a parameter
//!
//! `Fate<M>` carries whatever the party that ended the delivery wanted to say beyond the fact of the
//! ending, and `M` defaults to `()` because most endings have nothing to add. The framework's own
//! three sites all end deliveries at the default; the parameter is there for the deployment whose
//! shed carries a reason its own downstream knows how to read. It takes NO bound here — the single
//! bound is at the erased boundary, [`AckSender::fate`](super::AckSender::fate), exactly as
//! [`Lifecycle`](super::Lifecycle)'s own info parameter does and for the same reason.
use SignedDuration;
use ;
/// HOW A DELIVERY ENDED, where it ended without reaching a station.
///
/// # The terminals are CLOSED and the message is OPEN
///
/// The three variants are the whole table for the same reason
/// [`Lifecycle`](super::Lifecycle)'s four stations are: the framework MATCHES on them — the ack path
/// to decide what to answer, the tap path to decide what to say — so a fourth kind of ending would
/// be a thing neither knows how to perform. `M` is the opposite, and is whatever the party that
/// ended the delivery has to add.
///
/// `#[non_exhaustive]`, so a later concern's terminal is a widening: a matcher outside this crate
/// carries a wildcard and keeps compiling through it.
///
/// # Why it CLONES
///
/// One ending can be owed to SEVERAL senders. A keyed group's delivery is answered on the token of
/// every member that joined it — see [`Custody`](super::Custody) — and the ending they are told is
/// one ending, so it travels by value to each of them. `M: Clone` is the caller's to satisfy and the
/// framework's own three sites all end at `()`, which clones nothing.
// No `Unwrap`/`TryUnwrap` beside `IsVariant`, and it is the shape rather than a preference:
// `derive_more` refuses a struct variant ("cannot unwrap anonymous records"), and the payloads here
// are named fields because a shed carries three of them and a positional tuple would make the call
// site read `fate.0`. `terminal()` is the projection those derives would have been used for.
/// The terminal table on its own — what a tap counts and what an account balances against.
///
/// [`Station`](super::Station)'s sibling, and deliberately a separate word: a station is where an
/// item ARRIVED and a terminal is where a delivery ENDED, and an account that added them into one
/// column would be counting two different things.