コンテンツにスキップ

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

ItemPurpose
FormatDescriptorTrait implemented by readers and writers to describe format capabilities.
FormatHost-owned descriptor wrapper passed to describe_format().
FormatAttributesBit 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().

ConstantMeaning
NONENo special attributes.
LAYER_NUMBERSFormat supports numeric layers.
LAYER_NAMESFormat supports layer names.
LAYER_FILE_NAMESFormat stores layer names as file names.
LAYER_COMMENTSFormat supports layer comments.
LAYER_COLORSFormat supports layer colors.
LAYER_ELEVATIONFormat supports layer Z/elevation.
LAYER_FLASHED_RECTSFormat supports flashed rectangles.
LAYER_FLASHED_CIRCLESFormat supports flashed circles.
LAYER_FILLED_POLYGONSFormat supports filled polygons.
LAYER_OUTLINED_POLYSFormat supports outlined polygons.
LAYER_POLARITYFormat supports layer polarity metadata.
CELL_NUMBERSFormat supports numeric cells.
CELL_NAMESFormat supports cell names.
CELL_FILE_NAMESFormat stores cell names as file names.
CELL_NAMES_IGNORE_CASECell-name matching ignores case.
SUPPORT_BULGE_POLYGONSFormat supports polygon bulges.
MULTIPLE_FILESFormat reads or writes multiple files.
SINGLE_PASSFormat can be processed in a single pass.
DIRECTORY_OUTPUTFormat writes a directory.
DIRECTORY_INPUTFormat reads a directory.
SOURCE_INSPECTIONFormat supports source inspection metadata.

Format Methods

Format is supplied by the host. Plugin code sets descriptor values; the host applies validation during conversion.

MethodDescription
unsafe from_raw(ptr: *mut LcFormat) -> SelfWrap 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.