pub struct ProgressReporter { /* private fields */ }Expand description
Reports processing progress from a node back to the caller (UI, CLI, etc.).
Every callback is optional: a reporter with none is a no-op (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 reporter that receives percent updates.
The callback receives (percent 0-100, message). Count updates
(report_count) don’t reach it; use ProgressReporter::with_live
to receive both.
use bnto_core::ProgressReporter;
let reporter = ProgressReporter::new(|percent, message| {
println!("{}% — {}", percent, message);
});Sourcepub fn with_live(
live: impl Fn(LiveProgress, &str) + 'static,
output_callback: impl Fn(&str) + 'static,
) -> Self
pub fn with_live( live: impl Fn(LiveProgress, &str) + 'static, output_callback: impl Fn(&str) + 'static, ) -> Self
Create a reporter that receives every live update and command output line. The executor uses this to relay both as pipeline events.
Sourcepub fn throttled(
self,
clock: impl Fn() -> u64 + 'static,
interval_ms: u64,
) -> Self
pub fn throttled( self, clock: impl Fn() -> u64 + 'static, interval_ms: u64, ) -> Self
Let at most one live update through per interval_ms (the first one
always gets through). Command output lines are never throttled.
Sourcepub fn report(&self, percent: u32, message: &str)
pub fn report(&self, percent: u32, message: &str)
Report how far along the node is (0 to 100), with what it’s doing (“Compressing image 3/10…”).
Sourcepub fn report_count(&self, count: u64, message: &str)
pub fn report_count(&self, count: u64, message: &str)
Report work done so far when the node can’t know the total, e.g. files found while walking a folder. Call it as often as you like; a throttled reporter drops the excess.
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.