validate_gerber_files

Function validate_gerber_files 

Source
pub fn validate_gerber_files(
    files: &[String],
) -> Result<ValidationReport, Vec<String>>
Expand description

Validates a list of standardized Gerber filenames against a set of manufacturing rules. This function is pure: it takes a list of names and returns a result without any I/O.

§Arguments

  • files - A slice of strings, where each string is a filename that has already been renamed to the standard format (e.g., by the rename module).

§Returns

  • Ok(ValidationReport) - If all critical rules pass. The report includes the detected copper layer count and a list of warnings for non-critical issues (e.g., missing silkscreen or paste layers).
  • Err(Vec<String>) - If any critical rules fail. The vector contains a list of all error messages detailing what is missing or incorrect.
Examples found in repository?
examples/validation_check.rs (line 10)
6fn run_test_case(title: &str, files: &[String]) {
7    println!("--- Running Test Case: {} ---", title);
8    println!("Input Files: {:?}", files);
9
10    match validate_gerber_files(files) {
11        Ok(ValidationReport {
12            layer_count,
13            warnings,
14        }) => {
15            println!("\n[VALIDATION PASSED]");
16            println!("   - Detected Copper Layers: {}", layer_count);
17            if warnings.is_empty() {
18                println!("   - Warnings: None");
19            } else {
20                println!("   - Warnings:");
21                for warning in warnings {
22                    println!("     - {}", warning);
23                }
24            }
25        }
26        Err(errors) => {
27            println!("\n[VALIDATION FAILED]");
28            println!("   - Errors:");
29            for error in errors {
30                println!("     - {}", error);
31            }
32        }
33    }
34    println!("\n{}\n", "-".repeat(80));
35}