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

Wraps an optional boxed closure. Some(callback) for real reporting, None for no-op mode (used in tests).

Implementations§

Source§

impl ProgressReporter

Source

pub fn new(callback: impl Fn(u32, &str) + 'static) -> Self

Create a new ProgressReporter with a callback function.

The callback receives two arguments:

  1. progress (u32, 0-100) — percentage complete
  2. 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());
// });
Source

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.

Source

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

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 = 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.