pub struct ProgressReporter { /* private fields */ }Expand description
Reports processing progress from a node back to the caller (UI, CLI, etc.).
Wraps an optional boxed closure. Some(callback) for real reporting,
None for no-op mode (used in tests).
Implementations§
Source§impl ProgressReporter
impl ProgressReporter
Sourcepub fn new(callback: impl Fn(u32, &str) + 'static) -> Self
pub fn new(callback: impl Fn(u32, &str) + 'static) -> Self
Create a new ProgressReporter with a callback function.
The callback receives two arguments:
- progress (u32, 0-100) — percentage complete
- message (&str) — human-readable status text
USAGE:
use bnto_core::ProgressReporter;
// Simple logger
let reporter = ProgressReporter::new(|percent, message| {
println!("{}% — {}", percent, message);
});
// In a WASM bridge, wrap a js_sys::Function:
// let reporter = ProgressReporter::new(move |percent, message| {
// let _ = js_callback.call2(&JsValue::NULL, &percent.into(), &message.into());
// });Sourcepub fn new_noop() -> Self
pub fn new_noop() -> Self
Create a no-op reporter that discards all progress updates. Used in tests where we don’t need progress reporting.
Sourcepub fn with_output(
callback: impl Fn(u32, &str) + 'static,
output_callback: impl Fn(&str) + 'static,
) -> Self
pub fn with_output( callback: impl Fn(u32, &str) + 'static, output_callback: impl Fn(&str) + 'static, ) -> Self
Create a reporter with both progress and output callbacks.
The output callback receives streaming lines from child process stderr (e.g. yt-dlp download progress). Used by the executor to relay command output to PipelineEvent::CommandOutput.
Sourcepub fn report(&self, percent: u32, message: &str)
pub fn report(&self, percent: u32, message: &str)
Report progress to the caller.
Arguments:
percent— how far along we are (0 to 100)message— what we’re currently doing (“Compressing image 3/10…”)
Sourcepub fn report_output(&self, line: &str)
pub fn report_output(&self, line: &str)
Report a line of streaming output from a child process.
Called by processors that use run_command_streaming() to relay
stderr lines (e.g. yt-dlp progress) to the pipeline reporter.