Expand description
Stable C ABI over the cadkit facade.
The public contract is include/cadkit.h (hand-maintained; tests/header.rs checks that
every exported symbol is declared there) and the header-only C++17 wrapper
include/cadkit.hpp.
Design rules:
- Every function returns a
cadkit_status; output goes through out-pointers. - Every pointer argument is null-checked; no panic crosses the FFI boundary
(
catch_unwindturns it intocadkit_status::Panic). - The last error message is thread-local and owned by the library.
- Documents are immutable after creation. Live handles are tracked in a registry so that a
second
cadkit_document_freeor a use after free is reported ascadkit_status::InvalidHandleinstead of corrupting memory (best effort: a freed address that is reused by a new document is indistinguishable from the new one).
Re-exports§
pub use cadkit;
Structs§
- cadkit_
document - Opaque document handle. Create with
cadkit_read_*, release withcadkit_document_free. - cadkit_
info - Summary of a document (plain data, no ownership).
- cadkit_
options - Read options. Zero in a numeric field selects the library default;
NULLoptions select all defaults. Initialize withcadkit_options_initto be forward compatible. - cadkit_
svg_ options - SVG options. Initialize with
cadkit_svg_options_init.
Enums§
- cadkit_
dxf_ version - DXF output version. Values are part of the ABI.
- cadkit_
format - Detected file format. Values are part of the ABI.
- cadkit_
status - Result code of every fallible call. Values are part of the ABI.
Functions§
- cadkit_
bytes_ free - Releases a binary buffer returned by this library; NULL and previously freed pointers are no-ops.
- cadkit_
citygml_ ⚠preflight_ tkgm - Returns the local TKGM preflight report for native CityGML JSON.
profileis required:city-model-tenderordigital-building-registration. This never establishes official acceptance. Free the output withcadkit_string_free. - cadkit_
citygml_ ⚠read_ json - Reads a CityGML 2.0 XML buffer into its native object-graph JSON; release
*outwithcadkit_string_free. - cadkit_
citygml_ ⚠write_ json - Serializes native CityGML JSON to UTF-8 CityGML 2.0 XML;
validation_optionsfollows the Rustgml::ValidationOptionsJSON contract (NULL selects defaults). Release*outwithcadkit_string_free. - cadkit_
detect ⚠ - Detects the format from the header. Returns
CADKIT_FORMAT_UNKNOWNfor NULL data. - cadkit_
dgn_ ⚠strip_ seed - Copies a DGN V8 seed without the drawing content of its model and without the document
properties that name people or organisations (
dgn::strip_seed_v8).options_json_textfollows the Rustdgn::StripSeedOptionsJSON contract (an unknown field isInvalidArgument) andoptionssets the read limits; NULL selects the defaults of either. On success*out/*out_lenhold the seed (release withcadkit_bytes_free) and*report_jsonthedgn::StripSeedReportJSON (release withcadkit_string_free); on failure all three are NULL / 0. Names in the kept tables remain and are counted in the report; the result is not anonymous. - cadkit_
document_ ⚠convert_ units - Returns a new immutable document converted to the named length unit (e.g. “mm”, “meter”).
- cadkit_
document_ ⚠explode_ inserts - Returns a new immutable document with block references expanded up to
max_depth. Missing/cyclic/deeper references remain as inserts, as in RustDocument::explode_inserts. - cadkit_
document_ ⚠free - Releases a document. NULL is a no-op; a handle that is not live returns
CADKIT_INVALID_HANDLEand frees nothing. The handle must not be used afterwards. - cadkit_
document_ ⚠from_ json - Constructs a format-neutral document from its JSON representation.
- cadkit_
document_ ⚠info - Fills
outwith a summary ofdoc. - cadkit_
document_ ⚠info_ json - Returns the summary as a JSON object (format, version, application, counts, per-kind entity
counts).
*outis an owned string; free withcadkit_string_free. - cadkit_
document_ ⚠to_ citygml - Exports generic geometry as a UTF-8 CityGML 2.0 string; release
*outwithcadkit_string_free. - cadkit_
document_ ⚠to_ citygml_ with_ report - Returns JSON containing
xmland anExportReport. Free it withcadkit_string_free.metadata_onlymust be 0 (reject unsupported geometry) or 1 (retain it as metadata). Coordinates use the supplied CRS without conversion. Metadata is not rendered geometry. - cadkit_
document_ ⚠to_ dgn - Writes DGN V8 bytes using
seed. Release*outwithcadkit_bytes_free.options_json_textfollows the Rustdgn::WriteOptionsJSON contract; NULL selects defaults. - cadkit_
document_ ⚠to_ dxf - Writes the document as ASCII DXF of the given
cadkit_dxf_version. - cadkit_
document_ ⚠to_ dxf_ bytes - Writes DXF bytes with optional legacy code page; release with
cadkit_bytes_free. - cadkit_
document_ ⚠to_ json - Serializes the document to JSON (UTF-8).
*outis owned; free withcadkit_string_free. - cadkit_
document_ ⚠to_ svg - Renders one model as SVG.
optionsmay be NULL for defaults. - cadkit_
inspect_ ⚠bytes - Inspects an in-memory header and returns owned summary JSON; free with
cadkit_string_free. - cadkit_
inspect_ ⚠file - Inspects a file header and returns owned summary JSON; free with
cadkit_string_free. - cadkit_
last_ error_ message - Returns the message of the last failed call on this thread, or an empty string.
- cadkit_
options_ ⚠init - Fills
optionswith defaults. - cadkit_
read_ ⚠bytes - Reads a drawing from memory. The buffer is not retained.
- cadkit_
read_ ⚠file - Reads a drawing from a UTF-8 file path. On success
*outowns a document to free withcadkit_document_free; on failure*outis NULL. - cadkit_
status_ string - Returns a static description of a
cadkit_statusvalue. Never NULL; do not free. - cadkit_
string_ ⚠free - Frees a string returned by a
cadkit_document_*getter. NULL is a no-op. - cadkit_
svg_ ⚠options_ init - Fills
optionswith defaults (model 0, 1600 px wide, white background, text and blocks on). - cadkit_
version - Returns the library version, e.g.
"0.1.0". Static; never NULL; do not free.