Zum Inhalt springen

Rust Plugin API

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

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-plugin modules and when to use each one.
  • Python Scripting API — use Python instead of Rust when a script-level plugin is sufficient.

Core Concepts

ConceptRust APIPurpose
Format metadataFormatDescriptor, Format, FormatAttributesDescribes supported layer/cell capabilities and file extensions.
Import pluginsReaderParses source files and fills a LinkCAD drawing through DrawingBuilder.
Export pluginsWriterWrites drawings by enumerating cells, layers, and entities through WriterController.
Drawing constructionDrawingBuilderCreates cells, layers, polygons, polylines, arcs, text, references, and related metadata.
Drawing enumerationWriterControllerEnumerates layers, cells, fonts, transforms, and rendered entities during export.
Options UIDialogSpec, ChoiceItem, option helpersDeclares import/export option dialogs rendered by the host.
DiagnosticsEventLog, SeverityReports 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.