pub struct LayoutObservers<'a> { /* private fields */ }Expand description
Two-channel observer the layout engine threads through every
render entry point per ADR-0026. warn is required (the engine
uses it for segment-render error diagnostics); on_decision is
optional and receives a typed LayoutDecision per emit site.
The TUI live preview attaches on_decision to collect per-frame
status; the production stdout path doesn’t attach one, so
disabled-path cost is one Option::is_none() check per emit site
(struct construction is deferred behind Self::emit_with’s
closure, so even Cow::Owned user-config ids don’t allocate
when no observer is attached).
Single lifetime 'a because Rust unifies independent borrows to
their shortest common lifetime — a second lifetime parameter
would buy no flexibility for &mut dyn FnMut borrows.
Implementations§
Source§impl<'a> LayoutObservers<'a>
impl<'a> LayoutObservers<'a>
Sourcepub fn new(warn: &'a mut dyn FnMut(&str)) -> Self
pub fn new(warn: &'a mut dyn FnMut(&str)) -> Self
Construct with the required warn channel; no observer attached.
Sourcepub fn with_decision(
self,
on_decision: &'a mut dyn FnMut(&LayoutDecision),
) -> Self
pub fn with_decision( self, on_decision: &'a mut dyn FnMut(&LayoutDecision), ) -> Self
Attach an on_decision callback so the engine routes typed
LayoutDecision events through it at every emit site. Calling
twice replaces the previous callback (last-write-wins).