openbim_ifcx_binding_core/
lib.rs

1//! Host-independent core of the IFCX language bindings.
2//!
3//! The WebAssembly and Python bindings each wrap [`Document`] and
4//! [`LayerSet`] and hand their results to the host as JSON text, which the
5//! host parses into plain objects. The operations, the JSON shapes and the
6//! error codes live here once, so the hosts cannot drift apart: a fix or a
7//! new operation lands in one place and every binding exposes it.
8//!
9//! GLB export goes through `openbim-ifcx-geometry`: the composed layers
10//! become a render scene, written by its `to_glb`.
11//!
12//! This crate adds no IFCX behaviour of its own. It is a thin, host-shaped
13//! view of `openbim-ifcx`; if a binding needs more, that crate grows first.
14//!
15//! ```
16//! use openbim_ifcx_binding_core::LayerSet;
17//!
18//! let layer = br#"{
19//!     "header": {"id": "demo", "ifcxVersion": "ifcx_alpha", "dataVersion": "1.0.0",
20//!                "author": "someone", "timestamp": "2026-10-03"},
21//!     "imports": [], "schemas": {},
22//!     "data": [{"path": "site", "attributes": {"demo::name": "Site"}}]
23//! }"#;
24//! let mut layers = LayerSet::new();
25//! layers.push_layer(layer.to_vec());
26//! let tree: serde_json::Value = serde_json::from_str(&layers.compose_json()?).unwrap();
27//! assert_eq!(tree["children"]["site"]["attributes"]["demo::name"], "Site");
28//! # Ok::<(), openbim_ifcx_binding_core::BindingError>(())
29//! ```
30
31#![forbid(unsafe_code)]
32
33mod document;
34mod error;
35mod layers;
36mod report;
37mod tree;
38
39pub use document::Document;
40pub use error::BindingError;
41pub use layers::{GlbSettings, LayerSet};
42
43#[cfg(test)]
44mod fixtures {
45    //! The hand-written fixtures of `openbim-ifcx`, shared by the tests.
46
47    macro_rules! fixture {
48        ($name:literal) => {
49            include_bytes!(concat!("../../openbim-ifcx/tests/fixtures/", $name)).as_slice()
50        };
51    }
52    pub(crate) use fixture;
53}