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
//! Newtonian state machines: typed Harel configurations driven by an Elm loop.
//!
//! Unidirectional Configuration Architecture (UCA): XOR is an `enum`, AND is a
//! `struct`, [`update`](Machine::update) is the only door, history is a sidecar,
//! commands are data.
//!
//! # Four laws
//!
//! 1. The configuration is the type (`enum` XOR, `struct` AND).
//! 2. The only mutation protocol is TEA (`Msg` in, `Cmd` out).
//! 3. History is inertial and external (a sidecar, not live variants).
//! 4. Typestate is a façade; the interior is a configuration tree.
//!
//! A Newton machine **may lock itself**. Only the host gateway may lock the
//! wire. Only the venue can save you when both are dead.
//!
//! # Minimal machine
//!
//! ```
//! use newton_machine::prelude::*;
//!
//! struct Chart;
//! struct Model;
//!
//! impl Machine for Chart {
//! type Flags = ();
//! type Model = Model;
//! type Msg = ();
//! type Cmd = Cmd<()>;
//! type View = ();
//! type History = ();
//! type NodeId = &'static str;
//!
//! fn init(_: ()) -> Boot<Self> {
//! Boot::new(Chart, Model, (), Cmd::none())
//! }
//!
//! fn update(&mut self, _: &mut Model, _: &mut (), _: ()) -> Cmd<()> {
//! Cmd::none()
//! }
//!
//! fn view(&self, _: &Model) {}
//!
//! fn in_state(&self, _: &'static str) -> bool {
//! true
//! }
//! }
//!
//! let (mut rt, _) = Runtime::<Chart>::boot(());
//! let _ = rt.apply(());
//! ```
//!
//! Authors of hierarchical machines implement [`Topology`] and [`Transitional`],
//! then call [`perform()`] from [`Machine::update`]. Internal follow-ups go through
//! [`rtc()`] (return [`Storm`] via [`Machine::try_update`]; [`unwrap_storm`]
//! in `update`). Orthogonal regions: [`And`].
//!
//! GitHub carries runnable demos under `examples/` (not part of the crates.io
//! package). See the crate README.
//!
//! # Crate map
//!
//! | Module | Role |
//! | --- | --- |
//! | [`mod@machine`] / [`runtime`] | Elm loop: `init`, `update`, `try_apply`, `view` |
//! | [`topology`] / [`transition`] | Harel LCA: parent tree, exit/enter, `perform` |
//! | [`and`] | First-class Harel AND: [`And`] |
//! | [`rtc()`] / [`mod@rtc`] | Run-to-completion drain with a storm cap |
//! | [`cmd`] / [`sub`] / [`host`] | Effects as data; the host executes them |
//! | [`bits`] / chord / fleet | Host keys: bitset projection, chord table, N runtimes (`alloc`) |
//! | [`snapshot`] / [`history`] | `{config, context, history}` phase space |
//! | feature `macros` | `#[derive(Topology)]`, `#[derive(IntoNode)]`, `#[machine]`, [`perform!`] |
//!
//! [`prelude`] re-exports the types an author needs.
// rustbrain: [[docs/concepts/unidirectional-configuration-architecture]]
// rustbrain: [[docs/concepts/newtonian-state-machine]]
// rustbrain: [[docs/adr/0017-engine-is-topology-rtc-runtime]]
// rustbrain: [[docs/adr/0018-cmd-inline-then-heap]]
// rustbrain: [[docs/adr/0020-storm-panic-try-apply]]
// rustbrain: [[docs/adr/0021-and-combinator]]
// rustbrain: [[docs/adr/0022-sub-diff]]
// rustbrain: [[docs/adr/0023-chord-table-is-host-policy]]
// rustbrain: [[docs/adr/0024-macros-feature-hidden-proc-macro]]
// symbol:Machine symbol:Runtime symbol:Outcome symbol:Snapshot symbol:perform
extern crate alloc;
extern crate std;
pub use ;
pub use Bits;
pub use ;
pub use ;
pub use Combine;
pub use Fleet;
pub use ;
pub use ;
pub use ;
pub use Outcome;
pub use ;
pub use Runtime;
pub use Snapshot;
pub use ;
pub use ;
pub use ;
pub use ;