Expand description
ReadoutBinder — runtime adapter between the static
workload binding and the live display surface. See
SRD-63 §7.
Push 3 ships:
- The trait surface (
ReadoutBinder,ReadoutSink,LayoutHint,BinderKey,BakedBody,RenderStep). - A stateless
DefaultBinderthat walks each event’s bindings in order and renders. Stateful interactive variants (focus highlight, LOD overrides, overlay-held flag) land in Push 5. - A line-buffer
StringSinkthat the terminal-mode surface uses; the TUI gets its ownVec<Span>sink in Push 5.
Structs§
- Baked
Body - A baked readout body — the artifact the body-grammar parser produces at workload-load time. Cheap to clone (steps are owned, but small) and shared across event fires.
- Default
Binder - Stateless default binder. Holds a slot →
Vec<BakedBody>map; onfire(event)walks the matching slot’s bodies in declaration order. Push 5 introduces a statefulTuiReadoutBinderalongside. - String
Sink - Plain-text line buffer. Concatenates everything into a
single
String; layout hintsBlock/InlineCompactresolve to “insert a\nbefore/after Block, share surrounding spaces for Inline.” This is what the terminal-mode\r\x1b[K…rewriter consumes. - TuiReadout
Binder - Stateful runtime adapter for the TUI surface (SRD-63 §7).
Enums§
- Binder
Key - Keyboard events the interactive surface forwards to the
binder via
ReadoutBinder::on_key. Push 3’s stateless default binder ignores them; Push 5’sTuiReadoutBinderinterprets them. - Layout
Hint - What the binder writes to the sink for a single render
step. The sink decides how to honour the hint:
terminal-mode flattens to bytes; the TUI applies focus
decoration around
Focusedwrappers. - Layout
Mode - Layout intent expressed inside a readout body via the
layout=option. See SRD-63 §5.3.1. The binder maps this to aLayoutHintfor the sink at render time. - Render
Step - One step in a baked readout body. Either a literal run of text, a render call against a registered readout, or a colour / style directive (Push 4) that wraps the next step in ANSI on/off bytes.
Traits§
- Readout
Binder - Stateful runtime adapter — drives readouts in response to events, applies any interactive state (Push 5), emits ordered render instructions to the sink.
- Readout
Sink - Layout-aware writer the binder drives. Push 3 ships
StringSinkfor terminal-mode line emission; Push 5 adds a TUI sink that holdsVec<Span>.
Functions§
- build_
binder_ from_ workload - Build a
DefaultBinderfrom a workload-levelnmbrs_workload::model::ReadoutsBindings+ a fallback table of built-in defaults. The workload’s bound bodies replace the matching slot’s defaults; unbound slots fall through to whatever defaults the caller seeds. - build_
event_ binder - Build a binder bound to a single event slot, applying the SRD-63 §5.4.1 composition / override rules:
- build_
event_ binder_ with_ cli - Same as
build_event_binder, with a CLI--readoutoverride layered on top per SRD-63 §8 / Push 8. The override only applies to theUpdateslot (the only slot the single--readoutflag targets); other slots resolve through the workload + default path. Push 9+ could grow per-event override flags (--readout-on-each=…) if demand arises. - layout_
hint_ for - Per-step layout classification per SRD-63 §7.4.
modedoesn’t affect layout — the overlay shares shape and width with the value per §3.2 — so it isn’t an input here. The parameter stays in the signature so a future mode-aware layout (e.g. an “expand on Explanation” rule) doesn’t require changing every call site. - validate_
body_ for_ event - Bake-time validation: every Render step in
bodymust accept the firing slot’s subject kind. The binder calls this before binding, so a workload mistakenly bindingphase_statustoon_session_enderrors at workload- load instead of rendering silent zeros at run time.
Type Aliases§
- Readout
Handle - Reference-counted readout handle. The
Registryreturns these by wrapping unit-struct builtins inArc::new; per-workload custom readouts (planned for Push 4 of the SRD-63 follow-on work) ride the same shape. Cheap to clone — refcount bump only — and hands a&dyn Readoutout viaas_reffor the actual render call.