Skip to main content

process_batch

Function process_batch 

Source
pub fn process_batch<F>(
    src_dir: &Path,
    dst_dir: &Path,
    processor: F,
) -> Result<BatchResult>
where F: Fn(&Path, &Path) -> Result<u64>,
Expand description

Processes a batch of files through a streaming pipeline.

Applies processor to each file in src_dir, writing results to dst_dir. Processes files sequentially with constant memory. For parallel processing, use process_batch_parallel.

§Errors

Returns an error if any file cannot be read, processed, or written. Processing stops at the first error.

§Examples

use ssg::stream::{process_batch, stream_copy};
use tempfile::tempdir;
use std::fs;

let dir = tempdir().unwrap();
let src = dir.path().join("src");
let dst = dir.path().join("dst");
fs::create_dir(&src).unwrap();
fs::write(src.join("f.txt"), "x").unwrap();
let res = process_batch(&src, &dst, stream_copy).unwrap();
assert_eq!(res.files_processed, 1);