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 entryon_entry_complete: Called after successfully processing an entryon_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>
impl<'a> ProgressTracker<'a>
Sourcepub fn new(progress: &'a mut dyn ProgressCallback, total_entries: usize) -> Self
pub fn new(progress: &'a mut dyn ProgressCallback, total_entries: usize) -> Self
Creates a new progress tracker.
§Parameters
progress: Mutable reference to the progress callbacktotal_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);Sourcepub fn on_entry_start(&mut self, path: &Path)
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
Sourcepub fn on_entry_complete(&mut self, path: &Path)
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
Sourcepub fn on_complete(&mut self)
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more