FileProcessor

Struct FileProcessor 

Source
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

Source

pub fn new() -> Self

Creates a processor with default config.

Source

pub const fn with_config(config: Config) -> Self

Creates a processor with custom config.

Source

pub fn process<F, R>(&self, paths: &[PathBuf], f: F) -> BatchResult
where F: Fn(&Path, &str) -> Result<R> + Sync, R: Send,

Process files with custom operation.

Generic function for applying custom processing to files in parallel.

Source

pub fn parse_files(&self, paths: &[PathBuf]) -> BatchResult

Parse all files and return BatchResult.

Source

pub fn format_files( &self, paths: &[PathBuf], emitter_config: &EmitterConfig, ) -> Vec<(PathBuf, Result<String>)>

Format files and return (path, formatted_content) pairs.

Source

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for FileProcessor

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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, 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.