ProgressTracker

Struct ProgressTracker 

Source
pub struct ProgressTracker<'a> { /* private fields */ }
Expand description

Manages progress callbacks with automatic entry counting.

This struct consolidates progress-related state to reduce argument count in helper functions. It automatically tracks the current entry number and provides convenient methods for common progress reporting patterns.

§Batching

Progress callbacks are invoked at specific lifecycle points:

  • on_entry_start: Called before processing each entry
  • on_entry_complete: Called after successfully processing an entry
  • on_complete: Called once when the entire operation finishes

§Examples

use exarch_core::ProgressCallback;
use exarch_core::creation::progress::ProgressTracker;
use std::path::Path;

struct SimpleProgress;

impl ProgressCallback for SimpleProgress {
    fn on_entry_start(&mut self, path: &Path, total: usize, current: usize) {
        println!("[{}/{}] Processing: {}", current, total, path.display());
    }

    fn on_bytes_written(&mut self, bytes: u64) {}

    fn on_entry_complete(&mut self, path: &Path) {}

    fn on_complete(&mut self) {}
}

let mut progress = SimpleProgress;
let total_entries = 10;
let mut tracker = ProgressTracker::new(&mut progress, total_entries);

tracker.on_entry_start(Path::new("file1.txt"));
// ... process entry ...
tracker.on_entry_complete(Path::new("file1.txt"));

Implementations§

Source§

impl<'a> ProgressTracker<'a>

Source

pub fn new(progress: &'a mut dyn ProgressCallback, total_entries: usize) -> Self

Creates a new progress tracker.

§Parameters
  • progress: Mutable reference to the progress callback
  • total_entries: Total number of entries that will be processed
§Examples
use exarch_core::ProgressCallback;
use exarch_core::creation::progress::ProgressTracker;
use std::path::Path;

let mut progress = DummyProgress;
let tracker = ProgressTracker::new(&mut progress, 100);
Source

pub fn on_entry_start(&mut self, path: &Path)

Reports that processing started for an entry.

Automatically increments the current entry counter and invokes the on_entry_start callback.

§Parameters
  • path: Path of the entry being processed
Source

pub fn on_entry_complete(&mut self, path: &Path)

Reports that processing completed for an entry.

§Parameters
  • path: Path of the entry that was processed
Source

pub fn on_complete(&mut self)

Reports that the entire operation completed.

This should be called exactly once after all entries have been processed.

Auto Trait Implementations§

§

impl<'a> Freeze for ProgressTracker<'a>

§

impl<'a> !RefUnwindSafe for ProgressTracker<'a>

§

impl<'a> Send for ProgressTracker<'a>

§

impl<'a> !Sync for ProgressTracker<'a>

§

impl<'a> Unpin for ProgressTracker<'a>

§

impl<'a> !UnwindSafe for ProgressTracker<'a>

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> Same for T

Source§

type Output = T

Should always be Self
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.