pub struct ProgressTracker { /* private fields */ }Expand description
Tracks and displays progress for indexing operations
Thread-safe progress tracker that can be shared across threads. Uses atomic counters for file/chunk counts and throttling to prevent output flooding.
Implementations§
Source§impl ProgressTracker
impl ProgressTracker
Sourcepub fn new(mode: OutputMode) -> Self
pub fn new(mode: OutputMode) -> Self
Sourcepub fn set_totals(&self, files: usize, chunks: Option<usize>)
pub fn set_totals(&self, files: usize, chunks: Option<usize>)
Set total file and chunk counts
§Arguments
files- Total number of files to processchunks- Optional total number of chunks (embeddings)
Sourcepub fn update_files(&self, count: usize)
pub fn update_files(&self, count: usize)
Sourcepub fn update_chunks(&self, count: usize)
pub fn update_chunks(&self, count: usize)
Sourcepub fn should_print(&self) -> bool
pub fn should_print(&self) -> bool
Check if progress should be printed
Returns true if more than 200ms has elapsed since last print, preventing output flooding.
The first call always returns true to allow initial progress display.
Sourcepub fn print_progress(&self)
pub fn print_progress(&self)
Print current progress
Format depends on TTY status and output mode:
- Json: Outputs NDJSON progress events
- TTY: Overwrites line with \r
- Non-TTY: Prints new line every 10% progress
Sourcepub fn finish(&self)
pub fn finish(&self)
Print final timing summary
Prints completion message with total elapsed time. In JSON mode, emits a complete event.
Sourcepub fn files_processed(&self) -> usize
pub fn files_processed(&self) -> usize
Get the current count of processed files
Returns the number of files that have been processed so far. This can be used for statistics collection after scanning completes.
§Example
use maproom::progress::{ProgressTracker, OutputMode};
let tracker = ProgressTracker::new(OutputMode::Minimal);
tracker.update_files(42);
assert_eq!(tracker.files_processed(), 42);Sourcepub fn chunks_processed(&self) -> usize
pub fn chunks_processed(&self) -> usize
Get the current count of processed chunks
Returns the number of code chunks that have been processed so far. This can be used for statistics collection after scanning completes.
§Example
use maproom::progress::{ProgressTracker, OutputMode};
let tracker = ProgressTracker::new(OutputMode::Minimal);
tracker.update_chunks(100);
assert_eq!(tracker.chunks_processed(), 100);Sourcepub fn is_json_mode(&self) -> bool
pub fn is_json_mode(&self) -> bool
Check if the tracker is in JSON output mode
Returns true if the tracker was created with OutputMode::Json, which is used by the VSCode extension for programmatic consumption.
§Example
use maproom::progress::{ProgressTracker, OutputMode};
let json_tracker = ProgressTracker::new(OutputMode::Json);
assert!(json_tracker.is_json_mode());
let normal_tracker = ProgressTracker::new(OutputMode::Minimal);
assert!(!normal_tracker.is_json_mode());