pub trait Reporter: Send + Sync {
// Provided methods
fn diagnostic(&self, message: &str) { ... }
fn warn(&self, message: &str) { ... }
fn ai_usage(&self, usage: &AiUsage) { ... }
fn progress(&self, event: &ProgressEvent<'_>) { ... }
fn cancelled(&self) -> bool { ... }
}Expand description
A transport-agnostic sink for human-oriented core output.
Every method has a default no-op body, so an implementation opts into
exactly the channels it cares about — NoopReporter’s entire
implementation is empty. The trait is object-safe and Send + Sync
because engines hold it as Arc<dyn Reporter> across task boundaries.
Core code calls these methods with fully-formatted strings; deciding whether and where a message is shown (stdout, stderr, a GUI event channel, nowhere) belongs to the implementation.
§Examples
use subx_core::core::report::Reporter;
/// Only interested in warnings; silent on everything else.
struct WarningCounter(std::sync::atomic::AtomicUsize);
impl Reporter for WarningCounter {
fn warn(&self, message: &str) {
assert!(!message.is_empty());
self.0.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
}
let counter = WarningCounter(std::sync::atomic::AtomicUsize::new(0));
counter.diagnostic("hidden by this implementation");
counter.warn("counted");
assert_eq!(
counter.0.load(std::sync::atomic::Ordering::Relaxed),
1
);Provided Methods§
Sourcefn diagnostic(&self, message: &str)
fn diagnostic(&self, message: &str)
Human-oriented detail about work in progress. Not a failure.
§Arguments
message- Fully-formatted message text; may contain embedded\nseparators, written by the transport as one atomic block.
The terminal transport suppresses this channel in JSON output mode;
--quiet does not.
Sourcefn warn(&self, message: &str)
fn warn(&self, message: &str)
A non-fatal problem the operation recovered from or worked around.
§Arguments
message- Fully-formatted message text; may contain embedded\nseparators, written by the transport as one atomic block.
The terminal transport suppresses this channel in JSON output mode;
--quiet deliberately does not silence warnings.
Sourcefn ai_usage(&self, usage: &AiUsage)
fn ai_usage(&self, usage: &AiUsage)
Token accounting for one completed AI API call.
§Arguments
usage- The structured usage payload; implementations render or aggregate it as they see fit.
The terminal transport suppresses this channel in JSON output mode.
Sourcefn progress(&self, event: &ProgressEvent<'_>)
fn progress(&self, event: &ProgressEvent<'_>)
An event on the long-running-work progress stream.
§Arguments
event- The progress event; seeProgressEventfor coverage.
The terminal transport suppresses this channel in JSON output mode
and under --quiet — unlike diagnostics and warnings, progress
chatter is exactly what --quiet exists to remove.
Sourcefn cancelled(&self) -> bool
fn cancelled(&self) -> bool
Whether the operation being reported should stop early.
A long-running loop polls this between units of work — never inside
one — and closes its progress stream cleanly when it turns true.
Cancellation never surfaces as an Err: the loop finishes what it
has done, reports the shortfall through
ProgressEvent::Finished (done < total), and returns normally
(see the expose-core-orchestration-apis audit-loop contract). A
caller that wants a mid-await stop drops the future instead.
The default is false: reporters that do not implement this —
including NoopReporter and the terminal reporter — make every
loop run to completion, exactly as before this method existed.
§Returns
true when the driver has asked for an early stop.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".