Skip to main content

Crate laykit

Crate laykit 

Source
Expand description

§laykit

A production-ready Rust library for reading, writing, and manipulating GDSII and OASIS IC layout files.

§Features

  • Full GDSII Support - Read and write .gds files with all element types
  • Full OASIS Support - Read and write .oas files with all element types
  • Format Conversion - Convert between GDSII and OASIS formats
  • Streaming Parser - Process large files without loading into memory
  • CLI Tool - Command-line utility for file operations
  • Property Utilities - Enhanced property management and builders
  • Boolean / offset - Clipper2-backed (boolean, offset), same engine family as gdstk
  • AREF Expansion - Array reference expansion utilities
  • Minimal Dependencies - miniz_oxide for OASIS CBLOCK decompression; otherwise pure Rust
  • Memory Safe - Leverages Rust’s ownership system
  • Unified I/O - load, load_library, and Library::save for GDSII and OASIS

§Quick Start

§Reading a GDSII File

use laykit::GDSIIFile;

let gds = GDSIIFile::read_from_file("layout.gds")?;
println!("Library: {}", gds.library_name);
println!("Structures: {}", gds.structures.len());

§Creating a GDSII File

use laykit::{GDSIIFile, GDSStructure, GDSTime, GDSElement, Boundary};

let mut gds = GDSIIFile::new("MY_LIBRARY".to_string());
gds.units = (1e-6, 1e-9); // 1 micron user unit, 1nm database unit

let mut structure = GDSStructure {
    name: "TOP".to_string(),
    creation_time: GDSTime::now(),
    modification_time: GDSTime::now(),
    strclass: None,
    elements: Vec::new(),
};

structure.elements.push(GDSElement::Boundary(Boundary {
    layer: 1,
    datatype: 0,
    xy: vec![(0, 0), (1000, 0), (1000, 1000), (0, 1000), (0, 0)],
    elflags: None,
    plex: None,
    properties: Vec::new(),
}));

gds.structures.push(structure);

§Reading an OASIS File

use laykit::OASISFile;

let oasis = OASISFile::read_from_file("layout.oas")?;
println!("Cells: {}", oasis.cells.len());

§Format Conversion

use laykit::{GDSIIFile, converter};

// Convert GDSII to OASIS
let gds = GDSIIFile::read_from_file("input.gds")?;
let oasis = converter::gdsii_to_oasis(&gds)?;
oasis.write_to_file("output.oas")?;

§Modules

  • gdsii - GDSII format read/write (all 7 element types)
  • oasis - OASIS format read/write (all element types)
  • geometry - Geometric operations: bounding box, area, transforms, point-in-polygon
  • boolean_ops - Boolean operations: union, intersection, difference, xor, slice, offset
  • flexpath - Flexible paths with configurable joins and end caps
  • curve - Curve primitives: arc, Bezier, ellipse, spline, regular polygon
  • topology - Cell hierarchy: flatten, dependency order, top-level cells, library merge
  • converter - Format conversion (GDSII ↔ OASIS)
  • streaming - Streaming parser for large files (>1GB)
  • properties - Property management utilities
  • aref_expansion - Array reference expansion
  • format_detection - File format detection by magic bytes
  • layout - Unified load for GDSII and OASIS files

§Loading either format

use laykit::load_library;

let lib = load_library("layout.gds")?; // or .oas — format is auto-detected
println!("{} cells from {:?}", lib.cell_count(), lib.original_format());

Use load when you need the native on-disk representation without normalization.

Re-exports§

pub use boolean_ops::Axis;
pub use boolean_ops::BooleanOp;
pub use boolean_ops::DEFAULT_PRECISION;
pub use boolean_ops::boolean;
pub use boolean_ops::boolean_with_precision;
pub use boolean_ops::convex_hull;
pub use boolean_ops::offset;
pub use boolean_ops::offset_with_precision;
pub use boolean_ops::slice;
pub use boolean_ops::slice_at_positions;
pub use boolean_ops::slice_at_positions_with_precision;
pub use boolean_ops::slice_with_precision;
pub use curve::Curve;
pub use curve::ellipse;
pub use curve::regular_polygon;
pub use curve::rounded_rectangle;
pub use curve::spiral;
pub use curve::star;
pub use error::LaykitError;
pub use flexpath::EndCap;
pub use flexpath::FlexPath;
pub use flexpath::Join;
pub use flexpath::RobustPath;
pub use geometry::BoundingBox;
pub use geometry::affine_transform;
pub use geometry::bounding_box;
pub use geometry::bounding_box_i32;
pub use geometry::close_polygon;
pub use geometry::distance;
pub use geometry::ensure_clockwise;
pub use geometry::ensure_counter_clockwise;
pub use geometry::fillet;
pub use geometry::fracture_to_rectangles;
pub use geometry::gds_element_bounding_box;
pub use geometry::inside;
pub use geometry::is_counter_clockwise;
pub use geometry::library_bounding_box;
pub use geometry::mirror_x;
pub use geometry::mirror_y;
pub use geometry::oasis_element_bounding_box;
pub use geometry::point_in_any_polygon;
pub use geometry::point_in_polygon;
pub use geometry::polygon_area;
pub use geometry::polygon_centroid;
pub use geometry::polygon_perimeter;
pub use geometry::polygon_signed_area;
pub use geometry::remove_duplicates;
pub use geometry::rotate;
pub use geometry::scale;
pub use geometry::structure_bounding_box;
pub use geometry::translate;
pub use layout::LayoutFile;
pub use layout::LoadError;
pub use layout::LoadOptions;
pub use layout::SaveOptions;
pub use layout::load;
pub use layout::load_with_options;
pub use layout::save_layout;
pub use library::Library;
pub use library::load_library;
pub use topology::cell_dependencies;
pub use topology::dependency_order;
pub use topology::detect_cycles;
pub use topology::direct_references;
pub use topology::element_layer;
pub use topology::filter_by_layer;
pub use topology::flatten_structure;
pub use topology::layers_in_library;
pub use topology::layers_in_structure;
pub use topology::merge_library;
pub use topology::merge_library_overwrite;
pub use topology::top_level_cells;
pub use topology::total_element_count;
pub use topology::validate_hierarchy;
pub use aref_expansion::*;
pub use gdsii::*;
pub use oasis::*;
pub use properties::*;
pub use streaming::*;

Modules§

aref_expansion
boolean_ops
clipper_polytree
Clipper2 PolyTree execution + gdstk-style link_holes (see gdstk clipper_tools.cpp).
converter
curve
error
Typed errors for LayKit I/O and parsing.
flexpath
format_detection
File format detection utilities
gdsii
geom_cli
JSON geometry CLI for gdstk parity tests (laykit geom ...).
geometry
layout
Unified layout loading and saving for GDSII and OASIS files.
library
Canonical layout library (gdstk-style), normalized to GDSII structures internally.
oasis
properties
streaming
topology