Crate kiparse

Crate kiparse 

Source
Expand description

§KiParse

A KiCad file format parser for PCB and symbol files.

KiParse provides parsing capabilities for KiCad’s native file formats through a pragmatic approach focusing on what actually works with real-world files.

§Features

  • Layer Extraction: Fast and reliable layer information parsing from PCB files
  • Symbol Parsing: Complete symbol library parsing with metadata
  • Robust Error Handling: Detailed error messages with context
  • Memory Efficient: Optimized for large files
  • Well Tested: Works with real-world KiCad files

§Quick Start

use kiparse::prelude::*;
 
let pcb_content = r#"(kicad_pcb
  (version "20240108")
  (generator "pcbnew")
  (layers
    (0 "F.Cu" signal)
    (31 "B.Cu" signal)
  )
)"#;
 
let pcb = parse_layers_only(pcb_content)?;
 
println!("Found {} layers", pcb.layers.len());
for (id, layer) in &pcb.layers {
    println!("Layer {}: {} ({})", id, layer.name, layer.layer_type);
}

§Module Organization

  • pcb - PCB file layer extraction (.kicad_pcb)
  • symbol - Symbol library parsing (.kicad_sym)
  • error - Error types and handling

§Performance Characteristics

KiParse is designed for practical use with real PCB files:

  • Layer extraction: ~10MB/s
  • Symbol parsing: ~15MB/s
  • Memory usage: ~1.5x file size during parsing

Re-exports§

pub use error::KicadError;
pub use error::Result;
pub use pcb::parse_layers_only;
pub use pcb::detail_parser::DetailParser;
pub use symbol::symbol_parser::parse_symbol_lib;
pub use pcb::types::PcbFile;
pub use pcb::types::Layer;
pub use pcb::types::Track;
pub use pcb::types::Footprint;
pub use pcb::types::Pad;
pub use pcb::types::Via;
pub use pcb::types::Zone;
pub use pcb::types::Text;
pub use pcb::types::Graphic;
pub use pcb::types::Point;
pub use pcb::types::Rect;
pub use pcb::types::Arc;
pub use symbol::types::Symbol;

Modules§

error
pcb
PCB file parsing module for KiCad .kicad_pcb files
prelude
KiParse Prelude
symbol
Symbol library parsing module for KiCad .kicad_sym files

Constants§

VERSION
Library version information

Functions§

version
Returns version information for the library