Rust API Reference
The Rust plugin API is centered on lc-plugin, with geometry primitives from lc-types. Most plugins can import common symbols through lc_plugin::prelude::*; larger plugins may prefer explicit module imports.
Use the module pages below for practical signatures, method groups, examples, and links to equivalent Python APIs.
Module Overview
| Area | Module or Type | Use it for |
|---|---|---|
| Plugin traits and registration | Reader, Writer, FormatDescriptor, registration macros | Implement import/export behavior, format metadata, and the native GetPlugIn entry point. |
| Format metadata | lc_plugin::format | Set format attributes, file extensions, layer rules, and cell rules. |
| Import drawing construction | lc_plugin::builder::DrawingBuilder | Create cells, layers, shapes, references, text, progress, and import logs. |
| Export drawing access | lc_plugin::writer_ctrl::WriterController | Enumerate layers, cells, fonts, transformations, and rendered geometry. |
| Entities | lc_plugin::entity | Read polygons, polylines, arcs, ellipses, donuts, NURBS, text, references, layers, and cells. |
| Dialogs | lc_plugin::dialog | Declare host-rendered import/export option dialogs. |
| Options | lc_plugin::options | Register, read, and write typed plugin options. |
| Drawing helpers | lc_plugin::drawing | Run post-import drawing operations such as layer boolean and polarity merge. |
| Logging | lc_plugin::log | Report informational, warning, and error messages. |
| Source inspection | lc_plugin::inspect | Provide metadata used to populate dynamic import option dialogs. |
| Geometry and units | lc_types | Work with Point, Angle, Color, Resolution, and transforms. |
Import Lifecycle
- LinkCAD loads the native plugin library and calls the registration entry point.
- LinkCAD requests format metadata through
FormatDescriptor::describe_format. - For an import, LinkCAD calls
Reader::parse_filewith aDrawingBuilder. - The reader creates cells, selects layers, emits entities, logs messages, and returns
trueon success. - Optional
Reader::post_processhooks can run after parsing phases to merge layers or adjust the drawing.
Export Lifecycle
- LinkCAD calls
Writer::write_filewith aWriterController. - The writer configures rendering options, enumerates layers and cells, or lets LinkCAD render cells back through entity callbacks.
- Entity callback methods such as
write_polygon,write_arc, andwrite_textreceive geometry in host units. - The writer logs diagnostics and returns
truewhen the output file was written successfully.
Naming Conventions
Rust API names use snake_case methods and strongly typed enums. Coordinates and distances use LinkCAD database units through lc_types; convert source file units explicitly at the format boundary.
Python Counterparts
The Rust and Python plugin APIs share the same conceptual model. Use these pages when translating examples between native Rust plugins and embedded Python plugins:
linkcad.v1.plugin— reader/writer classes, low-level builder/controller wrappers, dialog metadata, plugin enums.linkcad.v1.db— drawing helpers, geometry entities, database enums, and direct scripting access.linkcad.v1.conv—FormatandFormatAttributesmetadata.linkcad.v1.env— options and event logging.