Crate openbim_ifcx

Source
Expand description

OpenBIM.rs family for IFC5 / IFCX.

IFCX is a layered, componentised JSON model with USD-like composition. It is not an EXPRESS schema release, so it lives here rather than as a SchemaVersion in openbim-ifc (see docs/adr/0001).

This crate reads and writes single ifcx_alpha files losslessly, composes layered nodes into a resolved tree (flatten, then compose(); see compose), and checks attribute values against a file’s schemas (IfcxFile::validate, validate_flat, validate_attributes; rules in validate). layers loads a file with its imports through a caller-supplied resolver, validates the stack as a whole (LayerStack::validate), and federates it into one file, ready to flatten and compose.

flatten_owned and layers::LayerStack::into_federated consume their input and move attribute values instead of copying them; use them when the nodes are not needed afterwards, which is the usual case after reading a file:

use openbim_ifcx::{compose, flatten_owned, IfcxFile};

let file = IfcxFile::from_json_str(r#"{
    "header": {"id": "demo", "ifcxVersion": "ifcx_alpha", "dataVersion": "1.0.0",
               "author": "someone", "timestamp": "2026-10-03"},
    "imports": [], "schemas": {},
    "data": [{"path": "site", "attributes": {"demo::name": "Site"}}]
}"#)?;
let composition = compose(&flatten_owned(file.data))?;
assert_eq!(composition.roots(), ["site"]);

§Features

  • integrity (default): check SHA-2 integrity values on imports. Without it, an import that carries integrity is rejected rather than loaded unchecked.
  • fs: layers::FsResolver, which loads imports from local files. The crate does no filesystem access otherwise and never uses the network.
use openbim_ifcx::IfcxFile;

let file = IfcxFile::from_json_str(r#"{
    "header": {"id": "demo", "ifcxVersion": "ifcx_alpha", "dataVersion": "1.0.0",
               "author": "someone", "timestamp": "2026-10-03"},
    "imports": [],
    "schemas": {},
    "data": [{"path": "a1", "children": {"Wall": "b2", "Old": null}}]
}"#)?;
let children = file.data[0].children.as_ref().unwrap();
assert_eq!(children["Wall"].as_deref(), Some("b2"));
assert_eq!(children["Old"], None);

Re-exports§

pub use compose::compose;
pub use compose::flatten;
pub use compose::flatten_owned;
pub use compose::ComposeError;
pub use compose::ComposedNode;
pub use compose::Composition;
pub use compose::FlatNode;
pub use validate::validate_attributes;
pub use validate::validate_flat;
pub use validate::validate_nodes;
pub use validate::FailureKind;
pub use validate::JsonType;
pub use validate::ValidationFailure;
pub use validate::ValidationReport;
pub use validate::INTERNAL_ATTRIBUTE_PREFIX;

Modules§

compose
Layer composition, following upstream src/ifcx-core/composition of buildingSMART/IFC5-development for the ifcx_alpha draft.
layers
Layer stacks: loading a main layer and, recursively, its imports.
validate
Checking attribute values against a file’s schemas.

Structs§

ArrayRestrictions
EnumRestrictions
IfcxFile
One IFCX file: a single layer of a dataset.
IfcxHeader
IfcxNode
One node opinion. children and inherits map a local name to a referenced path; a None value deletes that entry when layers merge.
IfcxSchema
Describes the values allowed for one attribute id.
IfcxValueDescription
ImportNode
A reference to another IFCX file that this layer builds on.
ObjectRestrictions
ReadError
A file that could not be read, with the 1-based location of the problem.
WriteError
A file that could not be written.

Enums§

DataType
The dataType of a value description. Names this crate does not know read as DataType::Other and are written back unchanged.
ReadErrorKind
Why a file could not be read.

Type Aliases§

Extra
Fields this crate does not model, kept in input order for round trip.