Skip to main content

Reporter

Struct Reporter 

Source
pub struct Reporter<'a> { /* private fields */ }
Expand description

Action-facing handle threaded into every action handler.

Implementations§

Source§

impl<'a> Reporter<'a>

Source

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.

Source

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.

Source

pub fn current_step(&self) -> Option<&StepId>

The current step, if any. Mostly useful for tests.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for Reporter<'a>

§

impl<'a> !RefUnwindSafe for Reporter<'a>

§

impl<'a> Send for Reporter<'a>

§

impl<'a> !Sync for Reporter<'a>

§

impl<'a> Unpin for Reporter<'a>

§

impl<'a> UnsafeUnpin for Reporter<'a>

§

impl<'a> !UnwindSafe for Reporter<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.