Skip to main content

Module batch

Module batch 

Source
Expand description

Batch command — process multiple 3MF/STL/OBJ files with a single invocation.

This module implements the core batch engine for the 3mf batch command. The batch pipeline:

  1. Expand glob patterns, walk directories, deduplicate inputs
  2. Detect file type from magic bytes (Zip3mf, Stl, Obj, Unknown)
  3. Filter files by requested operations (e.g. validate only applies to 3MF)
  4. Process files sequentially (jobs=1) or in parallel via rayon (jobs>1)
  5. Accumulate per-file results — never abort on single failure
  6. Emit text progress [N/M] or JSON Lines output per file
  7. Optionally print summary (totals + failed list)

SAFETY RULE: This module NEVER calls crate::commands::validate / stats / list. Those functions print directly to stdout and call std::process::exit(). Instead, we call lib3mf-core APIs directly:

  • model.validate(level) → ValidationReport
  • model.compute_stats(archiver) → ModelStats
  • archiver.list_entries() → Vec<String>

Structs§

BatchConfig
Top-level configuration for a batch run (passed to run()).
BatchOps
Set of operations to perform in a batch run.
FileError
Error record for a single failed operation on a file.
FileResult
Result of processing one file.

Enums§

DetectedFileType
Detected type of a file based on magic bytes / extension.
ErrorCategory
Error category for per-operation failures.

Functions§

detect_file_type
Reads magic bytes to classify a file’s type.
discover_files
Expands glob patterns, walks directories recursively (if recursive=true), and collects individual file paths. Deduplicates by canonical path.
process_file
Processes a single file, running all requested operations.
run
Entry point for the batch command.