hugr_model/lib.rs
1//! The data model of the HUGR intermediate representation.
2//!
3//! This crate defines data structures that capture the structure of a HUGR graph and
4//! all its associated information in a form that can be stored on disk. The data structures
5//! are not designed for efficient traversal or modification, but for simplicity and serialization.
6//!
7//! This crate supports version `
8#![doc = include_str!("../FORMAT_VERSION")]
9//! ` of the HUGR model format.
10mod capnp;
11
12pub mod v0;
13
14use std::sync::LazyLock;
15
16// This is required here since the generated code assumes it's in the package root.
17use capnp::hugr_v0_capnp;
18
19/// The current version of the HUGR model format.
20pub static CURRENT_VERSION: LazyLock<semver::Version> = LazyLock::new(|| {
21 // We allow non-zero patch versions, but ignore them for compatibility checks.
22 let v = semver::Version::parse(include_str!("../FORMAT_VERSION").trim())
23 .expect("`FORMAT_VERSION` in `hugr-model` contains version that fails to parse");
24 assert!(
25 v.pre.is_empty(),
26 "`FORMAT_VERSION` in `hugr-model` should not have a pre-release version"
27 );
28 v
29});