Rust Plugin API
The Rust plugin API lets compiled plugins add custom LinkCAD import and export formats. Use it when a format needs native performance, direct file parsing, or a reusable implementation that can be loaded by the LinkCAD host.
Rust plugins are built around the lc-plugin crate. The crate provides safe Rust traits and wrappers over the LinkCAD plugin C ABI, including drawing construction during import, drawing enumeration during export, format metadata, option dialogs, post-processing hooks, and event logging.
Start Here
- Getting Started — create a minimal reader plugin and register it with LinkCAD.
- API Reference — understand the main
lc-pluginmodules and when to use each one. - Python Scripting API — use Python instead of Rust when a script-level plugin is sufficient.
Core Concepts
| Concept | Rust API | Purpose |
|---|---|---|
| Format metadata | FormatDescriptor, Format, FormatAttributes | Describes supported layer/cell capabilities and file extensions. |
| Import plugins | Reader | Parses source files and fills a LinkCAD drawing through DrawingBuilder. |
| Export plugins | Writer | Writes drawings by enumerating cells, layers, and entities through WriterController. |
| Drawing construction | DrawingBuilder | Creates cells, layers, polygons, polylines, arcs, text, references, and related metadata. |
| Drawing enumeration | WriterController | Enumerates layers, cells, fonts, transforms, and rendered entities during export. |
| Options UI | DialogSpec, ChoiceItem, option helpers | Declares import/export option dialogs rendered by the host. |
| Diagnostics | EventLog, Severity | Reports import/export messages to LinkCAD users. |
Plugin Shape
A Rust plugin is compiled as a native dynamic library and exposes the LinkCAD GetPlugIn entry point through one of the registration macros:
lc_plugin::register_reader!for import-only formats.lc_plugin::register_writer!for export-only formats.lc_plugin::register_format!for combined import/export formats.
The host owns the plugin lifecycle. Implementations should return false for recoverable failures, log user-facing diagnostics through EventLog, and avoid panicking across the plugin boundary.