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
//! **THE STAGING LEDGER**: what a launch has already BUILT and still holds, and the goodbyes it says
//! when the walk refuses BEFORE anything ignited.
//!
//! [`Ignition::unwind`](super::Ignition::unwind) is the failed launch's duty for the values that
//! RAN. This is the same duty one moment earlier, and the difference between the two is not the
//! chain — it is one and the same — but WHERE THE VALUE IS.
//!
//! | when it fails | where the values are | how the chain reaches them |
//! |---|---|---|
//! | after ignition | on an engine | the party's own settlement seat, [`Settlement`](super::Wiring) |
//! | BEFORE ignition | in the launch walk's own hands | directly — this ledger, consumed |
//!
//! Post-ignition a running loop must be told, and the goodbye has to travel back from wherever the
//! value went. Pre-ignition NOTHING RUNS: ownership never left the walk, so there is no transport to
//! build. The values are consumed where they stand — a wired-but-unignited party through
//! [`Resident::into_operator`](crate::Resident::into_operator), a bare constructed value straight —
//! and what is written down is exactly what the shutdown's chain already understands: a
//! [`Farewell`] per enrolment, in enrolment order.
//!
//! # The ORDER is the launch's own, and it is written forwards
//!
//! Entries are staged as they are built and the chain says them BACKWARDS —
//! [`farewell`](super::teardown::farewell) is the one walk, so this ledger is in the order things
//! happened and nothing here reverses anything. The RESOURCES are not in it at all: they are the
//! [`Resources`](super::Resources)'s, released after this ledger is spent, which is the resources-last
//! rule read from the only place that can keep it.
//!
//! # Why the unwind that spends it is SYNCHRONOUS
//!
//! A goodbye is a [`Goodbye`](super::Goodbye) — a future that promises no `Send`, on purpose, so
//! that a value pinned to one thread can say one. An `async fn` unwind would hold that future across
//! its own await points and make the WHOLE emitted launch `!Send` for any deployment with one such
//! node. So [`Creation::unwind`](super::Creation::unwind) and
//! [`Wiring::unwind`](super::Wiring::unwind) are ordinary functions that drive the chain to its end
//! inside themselves, exactly as [`Ignition::unwind`](super::Ignition::unwind) does, and a launch
//! future stays as mobile as it was.
//!
//! # A value that enrolled nothing costs nothing to stage
//!
//! [`declared`](Staging::declared) reads [`Declared::TEARDOWN`](super::Declared::TEARDOWN) and drops
//! the value where it is `false`. No row, no allocation, no name in anybody's report — the same
//! economy the ignition keeps for a node that never wrote the word, spelled at the other end of the
//! launch.
use ;
/// The values a launch walk has BUILT and not yet handed on — the pre-ignition unwind's own list.
///
/// Filled by the party that holds the values, which is the launch walk itself: an emitted
/// `<Root>::launch` stages the node bag's remaining slots and each wired-but-unignited resident, and
/// a hand-written launch stages whatever it is holding. Spent by
/// [`Creation::unwind`](super::Creation::unwind) or [`Wiring::unwind`](super::Wiring::unwind),
/// whichever walk was the one that refused.
///
/// # Examples
///
/// ```
/// use ingraph::Staging;
/// # use ingraph::{Block, Buffered, Declared, Effect, Goodbye, Unchanneled};
///
/// struct Camera {
/// handle: u32,
/// }
///
/// # impl Declared for Camera {
/// # const EFFECT: Effect = Effect::Pure;
/// # const TEARDOWN: bool = true;
/// # type Channels = Unchanneled;
/// # type Mode = Block;
/// # type Options = ();
/// # type Pair = Buffered;
/// # type Wires<O> = ingraph::Downstream<O>;
/// # type Attribution<O> = ();
/// # fn goodbye(self) -> Goodbye {
/// # Box::pin(async move { let _ = self.handle; Ok(()) })
/// # }
/// # }
/// struct Counter;
/// # impl Declared for Counter {
/// # const EFFECT: Effect = Effect::Pure;
/// # type Channels = Unchanneled;
/// # type Mode = Block;
/// # type Options = ();
/// # type Pair = Buffered;
/// # type Wires<O> = ingraph::Downstream<O>;
/// # type Attribution<O> = ();
/// # }
///
/// let mut staged = Staging::new();
/// staged.declared::<Camera>("camera", Camera { handle: 7 });
/// // A declaration that wrote no `teardown` word is dropped as it is staged.
/// staged.declared::<Counter>("counter", Counter);
///
/// assert_eq!(staged.len(), 1);
/// ```