Expand description
The driving loop, as a value.
update(State, Msg) -> (State, Vec<Cmd>) is the product; driving it is five
lines that were written out longhand in six places, each with its own
spelling of the surrounding loop. Engine owns the reducer state and the
effect sink and exposes those five lines once:
inbox ── Msg ──► observer ──► update(State, Msg) ──► (State, Vec<Cmd>) ──► sinkThree seams, one per axis the callers actually differ on: EffectSink
(where a Cmd goes), StepObserver (what watches each message before the
reducer consumes it), and DrivePolicy (when the loop stops).
Engine::drive is an actor loop, and EngineHandle names its two ends
so something outside it — a daemon socket, a second view of one session, an
SDK client — can send messages in and watch what comes out.
Engine::reduce — the kernel — is synchronous and observer-free on
purpose: --replay folds a recorded log with no tokio runtime in sight, and
keeping the kernel callable from a plain for loop is what proves this
abstraction did not smuggle a runtime into the fold.
See docs/design/engine-extraction.md.
Structs§
- Drive
Policy - Everything that ends a drive, in one value.
- Drop
Effects - Discards every command.
--replay’s sink: the recorded log already holds each effect’s real-world result as a laterMsg, so re-running the effect would both duplicate it and make the fold impure. - Engine
- The reducer, its state, and where its commands go.
- Engine
Gone - The drive that owned this handle’s inbox has ended.
- Engine
Handle - A running engine, reachable from outside its drive.
- Inbox
- The messages a drive pumps.
- Observation
- One message, as seen before
updateconsumes it. - Step
Outcome - What one reduction did that a driver has to act on.
Enums§
- Drive
Exit - When
Engine::drivereturns. - OnCancel
- What a fired cancel token does to the drive.
- Stop
When - How far
Engine::driveruns.
Traits§
- Effect
Sink - Where a reducer-emitted
Cmdgoes. - Step
Observer - A hook on every message an
Enginepumps.