pub struct FileProcessor { /* private fields */ }Expand description
Parallel file processor for batch YAML operations.
Processes multiple YAML files in parallel using Rayon’s work-stealing scheduler. Automatically chooses optimal reading strategy based on file size (in-memory vs mmap).
§Security: Path Trust Boundary
This is a library crate providing file processing primitives. Path validation is the responsibility of the caller:
- For CLI tools: Validate paths before passing to this API
- For libraries: Document that paths must be trusted
- Path traversal: No canonicalization or “..” filtering is performed
- Symlinks: Followed without validation (use OS permissions for access control)
If your application accepts user-controlled paths, validate them before calling these methods. Example validation:
use std::path::{Path, PathBuf};
fn validate_path(path: &Path, base_dir: &Path) -> Result<PathBuf, String> {
let canonical = path.canonicalize()
.map_err(|e| format!("invalid path: {}", e))?;
if !canonical.starts_with(base_dir) {
return Err("path outside allowed directory".to_string());
}
Ok(canonical)
}Implementations§
Source§impl FileProcessor
impl FileProcessor
Sourcepub const fn with_config(config: Config) -> Self
pub const fn with_config(config: Config) -> Self
Creates a processor with custom config.
Sourcepub fn process<F, R>(&self, paths: &[PathBuf], f: F) -> BatchResult
pub fn process<F, R>(&self, paths: &[PathBuf], f: F) -> BatchResult
Process files with custom operation.
Generic function for applying custom processing to files in parallel.
Sourcepub fn parse_files(&self, paths: &[PathBuf]) -> BatchResult
pub fn parse_files(&self, paths: &[PathBuf]) -> BatchResult
Parse all files and return BatchResult.
Sourcepub fn format_files(
&self,
paths: &[PathBuf],
emitter_config: &EmitterConfig,
) -> Vec<(PathBuf, Result<String>)>
pub fn format_files( &self, paths: &[PathBuf], emitter_config: &EmitterConfig, ) -> Vec<(PathBuf, Result<String>)>
Format files and return (path, formatted_content) pairs.
Sourcepub fn format_in_place(
&self,
paths: &[PathBuf],
emitter_config: &EmitterConfig,
) -> BatchResult
pub fn format_in_place( &self, paths: &[PathBuf], emitter_config: &EmitterConfig, ) -> BatchResult
Format files in place (write back if changed).
Trait Implementations§
Source§impl Debug for FileProcessor
impl Debug for FileProcessor
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
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