pub struct BatchConfig {
pub parallel_threshold: usize,
pub max_threads: Option<usize>,
pub progress_interval: usize,
pub verbose: bool,
pub max_files: Option<usize>,
}Expand description
Configuration for batch processing operations.
Controls parallelization strategy, progress reporting, and error handling behavior.
§Examples
use hedl_cli::batch::BatchConfig;
// Default configuration (auto parallelization)
let config = BatchConfig::default();
// Custom configuration
let config = BatchConfig {
parallel_threshold: 5, // Parallelize if >= 5 files
max_threads: Some(4), // Use at most 4 threads
progress_interval: 10, // Update progress every 10 files
verbose: true, // Show detailed progress
max_files: Some(10_000), // Limit to 10,000 files
};Fields§
§parallel_threshold: usizeMinimum number of files to trigger parallel processing.
Files below this threshold are processed serially to avoid thread pool overhead. Default: 10
max_threads: Option<usize>Maximum number of threads to use for parallel processing.
When set, creates a local thread pool isolated to this batch operation. This ensures configuration always takes effect and prevents global state pollution.
§Behavior
None(default): Uses Rayon’s global thread pool (typically number of CPU cores)Some(n): Creates a local thread pool with exactlynthreads for this operation
§Thread Pool Isolation
Local thread pools provide complete isolation:
- No global state modification
- Concurrent batch operations can use different thread counts
- Configuration is guaranteed to take effect or error explicitly
- Thread pool lifetime matches the
process()call duration
§Performance Considerations
Local thread pool creation has small overhead (~0.5-1ms) and memory cost (~2-8MB per thread).
For maximum performance with default configuration, leave as None.
§Examples
use hedl_cli::batch::BatchConfig;
// Default: uses global pool
let config = BatchConfig::default();
// Custom: creates local pool with 4 threads
let config = BatchConfig {
max_threads: Some(4),
..Default::default()
};Default: None
progress_interval: usizeNumber of files between progress updates.
Progress is printed every N files processed. Set to 0 to disable. Default: 1 (update after each file)
verbose: boolEnable verbose progress reporting.
When true, shows file names and detailed status for each file. Default: false
max_files: Option<usize>Maximum number of files allowed in a batch operation.
This prevents resource exhaustion when processing very large file sets.
Some(n): Limit to n files (default: 10,000)None: No limit (use with caution)
§Security
Protects against:
- Memory exhaustion from storing millions of file paths
- File descriptor exhaustion from concurrent operations
- Excessive CPU time from unbounded processing
§Configuration
Can be overridden via:
- Environment variable:
HEDL_MAX_BATCH_FILES - CLI flag:
--max-files <N> - Programmatic:
BatchConfig { max_files: Some(n), .. }
§Examples
use hedl_cli::batch::BatchConfig;
// Default limit (10,000 files)
let config = BatchConfig::default();
// Custom limit
let config = BatchConfig {
max_files: Some(50_000),
..Default::default()
};
// Unlimited (use with caution)
let config = BatchConfig {
max_files: None,
..Default::default()
};Trait Implementations§
Source§impl Clone for BatchConfig
impl Clone for BatchConfig
Source§fn clone(&self) -> BatchConfig
fn clone(&self) -> BatchConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BatchConfig
impl Debug for BatchConfig
Auto Trait Implementations§
impl Freeze for BatchConfig
impl RefUnwindSafe for BatchConfig
impl Send for BatchConfig
impl Sync for BatchConfig
impl Unpin for BatchConfig
impl UnwindSafe for BatchConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more