Skip to main content

ProgressReporter

Struct ProgressReporter 

Source
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

Source

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);
});
Source

pub fn new_noop() -> Self

Create a no-op reporter that discards all progress updates.

Source

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.

Source

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.

Source

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…”).

Source

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.

Source

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.

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.