BatchProcessor

Struct BatchProcessor 

Source
pub struct BatchProcessor { /* private fields */ }
Expand description

High-performance batch processor for HEDL files.

Orchestrates parallel or serial processing based on configuration and workload. Provides progress tracking and comprehensive error collection.

§Thread Safety

BatchProcessor is thread-safe and can be shared across threads via Arc.

§Examples

use hedl_cli::batch::{BatchProcessor, BatchConfig, ValidationOperation};
use std::path::PathBuf;

let processor = BatchProcessor::new(BatchConfig {
    parallel_threshold: 5,
    verbose: true,
    ..Default::default()
});

let files: Vec<PathBuf> = vec![
    "file1.hedl".into(),
    "file2.hedl".into(),
];

let results = processor.process(
    &files,
    ValidationOperation { strict: false },
    true,
)?;

if results.has_failures() {
    eprintln!("Some files failed validation");
    for failure in results.failures() {
        eprintln!("  - {}: {:?}", failure.path.display(), failure.result);
    }
}

Implementations§

Source§

impl BatchProcessor

Source

pub fn new(config: BatchConfig) -> Self

Create a new batch processor with the given configuration.

Source

pub fn default_config() -> Self

Create a batch processor with default configuration.

Source

pub fn process<O>( &self, files: &[PathBuf], operation: O, show_progress: bool, ) -> Result<BatchResults<O::Output>, CliError>
where O: BatchOperation,

Process multiple files with the given operation.

Automatically selects parallel or serial processing based on configuration and file count. Provides progress reporting and collects all results.

§Arguments
  • files - Slice of file paths to process
  • operation - The operation to perform on each file
  • show_progress - Whether to show progress updates
§Returns
  • Ok(BatchResults) - Always succeeds and collects all individual results
  • Err(CliError) - Only on catastrophic failures (e.g., thread pool creation)
§Performance
  • Uses parallel processing if files.len() >= config.parallel_threshold
  • Serial processing for small batches to avoid thread pool overhead
  • Lock-free progress tracking using atomic counters
§Examples
use hedl_cli::batch::{BatchProcessor, BatchConfig, FormatOperation};
use std::path::PathBuf;

let processor = BatchProcessor::default_config();
let files = vec![PathBuf::from("a.hedl"), PathBuf::from("b.hedl")];

let results = processor.process(
    &files,
    FormatOperation {
        check: false,
        ditto: true,
        with_counts: false,
    },
    true,
)?;

println!("Formatted {} files", results.success_count());

Trait Implementations§

Source§

impl Clone for BatchProcessor

Source§

fn clone(&self) -> BatchProcessor

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BatchProcessor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,