pub struct Reporter<'a> { /* private fields */ }Expand description
Action-facing handle threaded into every action handler.
Implementations§
Source§impl<'a> Reporter<'a>
impl<'a> Reporter<'a>
Sourcepub fn new(
event_tx: &'a Sender<ExecEvent>,
cmd_rx: &'a Receiver<UiCommand>,
transcript: &'a mut dyn TranscriptSink,
) -> Self
pub fn new( event_tx: &'a Sender<ExecEvent>, cmd_rx: &'a Receiver<UiCommand>, transcript: &'a mut dyn TranscriptSink, ) -> Self
Build a reporter bound to the given channels and transcript sink.
Sourcepub fn set_current_step(&mut self, step: Option<StepId>)
pub fn set_current_step(&mut self, step: Option<StepId>)
Set the step that subsequent log lines and progress signals are attributed to. Called by the executor at each step boundary.
Sourcepub fn current_step(&self) -> Option<&StepId>
pub fn current_step(&self) -> Option<&StepId>
The current step, if any. Mostly useful for tests.
Sourcepub fn fact(&mut self, fact: StepFact) -> Result<(), ReporterError>
pub fn fact(&mut self, fact: StepFact) -> Result<(), ReporterError>
Record a transcript-worthy fact.
Facts are the audit record: everything durable flows through here, and
it comes from an action in the plan (plus the runner’s own lifecycle
facts). Writes to the transcript sink synchronously, then forwards to
the UI as ExecEvent::Fact. The transcript is flushed before the UI
observes the fact. To surface something to the operator without
recording it, use Reporter::signal / Reporter::log instead.
§Errors
Returns ReporterError::Transcript if the sink fails to persist,
or ReporterError::Disconnected if the frontend is gone.
Sourcepub fn signal(&mut self, signal: UiSignal) -> Result<(), ReporterError>
pub fn signal(&mut self, signal: UiSignal) -> Result<(), ReporterError>
Emit a raw UiSignal. Never recorded to the transcript.
Signals are ephemeral operator-assistance: a frontend may drop any of
them without affecting correctness or the transcript. They are never
promoted into the audit record; use Reporter::fact for anything
that must persist. Most callers should use the specialized helpers
(Reporter::log for narration, Reporter::progress for spinners).
This method exists for structured signals (e.g. the pre-ceremony
overview, the system snapshot) that don’t fit either shape.
§Errors
Returns ReporterError::Disconnected if the frontend is gone.
Sourcepub fn log(
&mut self,
icon: Icon,
text: impl Into<String>,
) -> Result<(), ReporterError>
pub fn log( &mut self, icon: Icon, text: impl Into<String>, ) -> Result<(), ReporterError>
Emit a UI-only narration line. Never recorded to the transcript.
§Errors
Returns ReporterError::Disconnected if the frontend is gone.
Sourcepub fn progress(
&mut self,
phase: impl Into<String>,
fraction: Option<f32>,
) -> Result<(), ReporterError>
pub fn progress( &mut self, phase: impl Into<String>, fraction: Option<f32>, ) -> Result<(), ReporterError>
Emit a progress signal (e.g. spinner phase, completion fraction).
Never recorded to the transcript. Requires a current step.
§Errors
Returns ReporterError::Disconnected or
ReporterError::NoCurrentStep.
Sourcepub fn check_abort(&mut self) -> Result<(), ReporterError>
pub fn check_abort(&mut self) -> Result<(), ReporterError>
Drain any pending commands. Returns ReporterError::Aborted if an
abort command is in the queue.
Designed to be called liberally during long-running backend
operations. try_recv on a crossbeam channel is on the order of
nanoseconds, so the cost is negligible.
§Errors
Returns ReporterError::Aborted if abort was requested, or
ReporterError::Disconnected if the frontend went away.
Sourcepub fn prompt(&mut self, prompt: &Prompt) -> Result<Response, ReporterError>
pub fn prompt(&mut self, prompt: &Prompt) -> Result<Response, ReporterError>
Issue a prompt and block until a validated response is received.
While blocking, also handles UiCommand::Abort and
UiCommand::LogDeviation so the user can deviate or abort mid-prompt.
On rejection by the runtime’s validator, re-emits the prompt with
the rejection reason attached so the frontend can surface it.
Automatically emits StepFact::PromptAnswered when the response
is accepted.
§Errors
Returns ReporterError::Aborted if abort was requested,
ReporterError::Disconnected if the frontend went away, or
ReporterError::Transcript if the fact cannot be recorded.