core linkml schema operations written in rust
- linkml_meta (
src/metamodel): Autogenerated LinkML metamodel types and helpers. Optional Serde/PyO3 features for serialization and Python interop. - schemaview (
src/schemaview): Schema loading, CURIE/URI conversion, resolution (feature-gated), and view utilities:SchemaView,ClassView,SlotView,EnumView. - linkml_runtime (
src/runtime): Core runtime:LinkMLInstanceparsing (YAML/JSON), basic validation, diff/patch, and Turtle serialization. Pure Rust library. - linkml_tools (
src/tools): CLI tools wrapping the runtime and schemaview:linkml-validate,linkml-convert,linkml-diff,linkml-patch,linkml-schema-validate.
- linkml_runtime_python (
src/python): PyO3 bindings and Python package (linkml_runtime_rust._native) exposing SchemaView and LinkMLInstance to Python; includes small Python helpers. - linkml_wasm (
src/wasm): WASM build target (experimental).
SchemaView instances can be serialized into a snapshot—a self-contained YAML payload that carries
every loaded schema definition along with the resolved-import lineage and primary-schema pointer. The
snapshot can be reconstructed into an equivalent SchemaView without contacting remote import targets,
making it ideal for building views server-side and shipping them to Python, WASM, or browser clients.
- Rust:
SchemaView::to_snapshot_yaml()/SchemaView::from_snapshot_yaml(...) - Python:
SchemaView.to_snapshot_yaml(),SchemaView.from_snapshot_yaml(...) - WASM/JS:
JsSchemaView::toSnapshotYaml(),schemaview_from_snapshot_yaml(...)
In order to regenerate the metamodel:
- Make sure you have a python virtual env with linkml_runtime (python!) installed, and that its active
- In the
../linkmlfolder there should be a linkml checkout that is on a branch with the rust generator - run the
regen.shscript from the root of this repo
Note that now the metamodel is generated from src/schemaview/tests/data/meta.yaml.
- generate the metamodel directly from the linkml meta repository
- Create a virtual env and activate it
- Install maturin (pip install maturin)
- From repo root, run:
maturin develop -m src/python/Cargo.toml(or use your venv:../env/bin/maturin develop -m src/python/Cargo.toml)
Now the linkml_runtime_rust module should be accessible.
- Build all crates:
cargo build --workspace - Run all tests:
cargo test --workspace - Format:
cargo fmt --all(check:cargo fmt --all -- --check) - Lint:
cargo clippy --workspace --all-targets --all-features --exclude linkml_meta -- -D warnings --no-deps(excludes autogeneratedlinkml_meta)