Skip to main content

Crate sbol_rulegen

Crate sbol_rulegen 

Source
Expand description

Build-time code generator that turns a versioned SBOL validation rules.toml into Rust rule-catalog source.

The sbol2 and sbol3 crates each call generate from their build.rs, pointing at their own rules.toml. This keeps one generator, one set of catalog invariants, and one emitted shape across both data-model versions.

Cold-compile cost on a fresh target/ dir is roughly 30s because of the toml+serde dep stack. Subsequent builds reuse the cached deps; a caller re-runs the script only when its rules.toml, build.rs, or policies directory changes (the caller emits the cargo:rerun-if-changed directives).

Outputs into out_dir:

  • rule_catalog.rs: VALIDATION_RULE_STATUSES slice literal, sorted by rule id for diff stability.
  • rule_spec_meta.rs: the VALIDATION_RULE_SPEC_* constants sourced from the TOML [meta] block.

Failures (TOML parse error, unknown enum variant, missing required field, missing policy ADR) panic with a message that names the offending rule id and field, so a build failure points straight at the bad entry.

Functionsยง

generate
Generates rule_catalog.rs and rule_spec_meta.rs into out_dir from the rules.toml at rules_toml.