pub trait BatchOperation: Send + Sync {
type Output: Send;
// Required methods
fn process_file(&self, path: &Path) -> Result<Self::Output, CliError>;
fn name(&self) -> &str;
}Expand description
Trait for batch operations on HEDL files.
Implement this trait to define custom batch operations. The operation must be thread-safe (Send + Sync) to support parallel processing.
§Type Parameters
Output- The type returned on successful processing of a file
§Examples
use hedl_cli::batch::BatchOperation;
use hedl_cli::error::CliError;
use std::path::Path;
struct CountLinesOperation;
impl BatchOperation for CountLinesOperation {
type Output = usize;
fn process_file(&self, path: &Path) -> Result<Self::Output, CliError> {
let content = std::fs::read_to_string(path)
.map_err(|e| CliError::io_error(path, e))?;
Ok(content.lines().count())
}
fn name(&self) -> &str {
"count-lines"
}
}