pub struct FileProcessor { /* private fields */ }Expand description
Unified file processor that handles both parallel and sequential processing
Implementations§
Source§impl FileProcessor
impl FileProcessor
Sourcepub const fn with_config(config: ProcessorConfig) -> Self
pub const fn with_config(config: ProcessorConfig) -> Self
Create a new file processor with custom configuration
Sourcepub fn process_files_streaming<T, F, A>(
&self,
files: &[String],
line_processor: F,
aggregator: A,
initial: T,
) -> Result<(T, ProcessStats)>
pub fn process_files_streaming<T, F, A>( &self, files: &[String], line_processor: F, aggregator: A, initial: T, ) -> Result<(T, ProcessStats)>
Process multiple files with a streaming line-by-line processor
This is the main entry point for file processing. It automatically handles:
- Progress tracking with accurate totals and ETA
- Parallel or sequential processing based on configuration
- Error handling and context
- Memory-efficient streaming
§Arguments
files- List of file paths to processline_processor- Function that processes individual audit entriesaggregator- Function that combines results from all filesinitial- Initial value for the aggregator
§Example
ⓘ
let processor = FileProcessor::new();
let result = processor.process_files_streaming(
&files,
|entry, state| {
// Process each audit entry
state.counter += 1;
},
|acc, file_result| {
// Combine results from each file
acc.merge(file_result)
},
MyState::new(),
)?;Sourcepub fn process_files_collect<T, F>(
&self,
files: &[String],
processor: F,
) -> Result<(Vec<T>, ProcessStats)>
pub fn process_files_collect<T, F>( &self, files: &[String], processor: F, ) -> Result<(Vec<T>, ProcessStats)>
Process multiple files and collect results into a collection
This is a convenience method for cases where you want to collect individual results from each file rather than aggregating.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileProcessor
impl RefUnwindSafe for FileProcessor
impl Send for FileProcessor
impl Sync for FileProcessor
impl Unpin for FileProcessor
impl UnwindSafe for FileProcessor
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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