Format Metadata
このコンテンツはまだ日本語訳がありません。
lc_plugin::format describes file-format capabilities and validation rules. LinkCAD calls FormatDescriptor::describe_format() before import/export work starts so the plugin can declare layer support, cell support, valid names, and file-name extension behavior.
Python exposes a matching descriptor API through linkcad.v1.conv.Format and FormatAttributes.
Key Public Items
| Item | Purpose |
|---|---|
FormatDescriptor | Trait implemented by readers and writers to describe format capabilities. |
Format | Host-owned descriptor wrapper passed to describe_format(). |
FormatAttributes | Bit flags for format capabilities. |
FormatDescriptor
pub trait FormatDescriptor { fn describe_format(&self, fmt: &mut Format);}Implement this trait on the same type that implements Reader, Writer, or both.
impl FormatDescriptor for ExampleReader { fn describe_format(&self, fmt: &mut Format) { fmt.set_attributes(FormatAttributes::LAYER_NAMES | FormatAttributes::CELL_NAMES); fmt.set_layer_name_length(64); fmt.set_cell_name_length(64); fmt.set_file_name_extension("exa"); }}FormatAttributes
FormatAttributes is a namespace of u32 bit-flag constants. Combine values with | and pass the result to Format::set_attributes().
| Constant | Meaning |
|---|---|
NONE | No special attributes. |
LAYER_NUMBERS | Format supports numeric layers. |
LAYER_NAMES | Format supports layer names. |
LAYER_FILE_NAMES | Format stores layer names as file names. |
LAYER_COMMENTS | Format supports layer comments. |
LAYER_COLORS | Format supports layer colors. |
LAYER_ELEVATION | Format supports layer Z/elevation. |
LAYER_FLASHED_RECTS | Format supports flashed rectangles. |
LAYER_FLASHED_CIRCLES | Format supports flashed circles. |
LAYER_FILLED_POLYGONS | Format supports filled polygons. |
LAYER_OUTLINED_POLYS | Format supports outlined polygons. |
LAYER_POLARITY | Format supports layer polarity metadata. |
CELL_NUMBERS | Format supports numeric cells. |
CELL_NAMES | Format supports cell names. |
CELL_FILE_NAMES | Format stores cell names as file names. |
CELL_NAMES_IGNORE_CASE | Cell-name matching ignores case. |
SUPPORT_BULGE_POLYGONS | Format supports polygon bulges. |
MULTIPLE_FILES | Format reads or writes multiple files. |
SINGLE_PASS | Format can be processed in a single pass. |
DIRECTORY_OUTPUT | Format writes a directory. |
DIRECTORY_INPUT | Format reads a directory. |
SOURCE_INSPECTION | Format supports source inspection metadata. |
Format Methods
Format is supplied by the host. Plugin code sets descriptor values; the host applies validation during conversion.
| Method | Description |
|---|---|
unsafe from_raw(ptr: *mut LcFormat) -> Self | Wrap a host descriptor pointer. Used by ABI glue. |
set_attributes(attributes: u32) | Set capability flags. |
set_layer_number_range(min: i32, max: i32) | Set valid layer-number range. |
set_layer_name_length(length: i32) | Set maximum layer-name length. |
set_valid_layer_chars(char_set: &str, initial_chars: &str, preferred_prefix: &str) | Set valid layer-name characters and default prefix. |
set_cell_number_range(min: i32, max: i32) | Set valid cell-number range. |
set_cell_name_length(length: i32) | Set maximum cell-name length. |
set_valid_cell_chars(char_set: &str, initial_chars: &str, preferred_prefix: &str) | Set valid cell-name characters and default prefix. |
set_file_name_extension(ext: &str) | Set the cell file-name extension. |
Practical Descriptor Example
impl FormatDescriptor for ExampleFormat { fn describe_format(&self, fmt: &mut Format) { fmt.set_attributes( FormatAttributes::LAYER_NUMBERS | FormatAttributes::LAYER_NAMES | FormatAttributes::CELL_NAMES | FormatAttributes::MULTIPLE_FILES, );
fmt.set_layer_number_range(0, 255); fmt.set_layer_name_length(32); fmt.set_valid_layer_chars( "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", "ABCDEFGHIJKLMNOPQRSTUVWXYZ_", "L", );
fmt.set_cell_name_length(64); fmt.set_file_name_extension("exa"); }}Source Inspection Attribute
Set FormatAttributes::SOURCE_INSPECTION when the plugin registers a SourceInspector and uses dialog widgets with dynamic inspection_key values.