Skip to main content

ifc_schema/
lib.rs

1//! `ifc-schema` — the IFC schema **as data**, not as 2,500 generated structs.
2//!
3//! # The decision
4//!
5//! IfcOpenShell generates a class per IFC entity per schema version. That is a
6//! very large amount of code, and it must be regenerated for every schema
7//! release. This crate instead reads the normative EXPRESS files into tables
8//! and answers questions against them.
9//!
10//! The evidence that this is the right call: IFC4x3 renames
11//! `IfcBuildingElement` to `IfcBuiltElement` and drops `IfcProxy` and the whole
12//! `*StandardCase` family. Generated types would fork the entire API surface;
13//! a table just holds different rows.
14//!
15//! # What this crate is for
16//!
17//! | Module | Role |
18//! | --- | --- |
19//! | [`version`] | Which schema a file declares |
20//! | `express` | Parsing `.exp` source (opt-in `express` feature) |
21//! | [`entity`] | Entity descriptors: name, supertype, slots |
22//! | [`attribute`] | Attribute descriptors and declared types |
23//! | [`types`] | Defined types, enumerations, selects |
24//! | [`registry`] | The assembled, queryable schema |
25//!
26//! # Relationship to the model
27//!
28//! `ifc-model` does **not** depend on this crate.
29//! The model stores whatever a file contains, valid or not. The schema is what
30//! you consult to *interpret* what was stored, and it is optional: a file whose
31//! schema is unknown still parses, and its entities still round-trip.
32//!
33//! # Features
34//!
35//! | Feature | Default | Provides |
36//! | --- | --- | --- |
37//! | `ifc2x3`, `ifc4`, `ifc4x1`, `ifc4x2`, `ifc4x3` | yes | That release's bundled table and accessor (`ifc2x3()`, ...) |
38//! | `artifact` | via any release | The compiled-artifact decoder |
39//! | `express` | no | `Schema::from_express` through `openbim-step` |
40//! | `generation` | no | The artifact generator binary |
41//!
42//! A default build bundles every release. A build that turns defaults off
43//! and names one release still recognises every [`SchemaVersion`], and
44//! [`for_version`] refuses the others with [`NotBundled`] -- a typed error,
45//! never a panic, and distinct from an unknown header token.
46//!
47//! # Owned declaration types
48//!
49//! [`EntityDef`], [`Attribute`], [`TypeDef`], [`TypeKind`] and [`WhereRule`]
50//! belong to this crate and are `#[non_exhaustive]`. The bundled tables
51//! decode straight into them without any parser crate; the `openbim-step`
52//! EXPRESS extractor is linked only by the opt-in `express` feature (for
53//! `Schema::from_express`) and by `generation`.
54//!
55//! ```
56//! # #[cfg(feature = "ifc4")] {
57//! let schema = ifc_schema::ifc4();
58//! assert!(schema.is_a("IFCWALL", "IfcRoot"));
59//! assert_eq!(
60//!     &schema.attribute_names("IfcWall")[..2],
61//!     ["GlobalId", "OwnerHistory"]
62//! );
63//! # }
64//! ```
65
66#[cfg(feature = "artifact")]
67mod artifact;
68pub mod attribute;
69mod bundled;
70pub mod completeness;
71pub mod entity;
72pub mod export;
73#[cfg(feature = "express")]
74mod express;
75pub mod registry;
76pub mod types;
77pub mod version;
78
79#[cfg(feature = "artifact")]
80pub use artifact::decode_schema as artifact_decode_schema;
81#[cfg(feature = "generation")]
82pub use artifact::encode_schema as artifact_encode_schema;
83#[cfg(feature = "artifact")]
84pub use artifact::BundledSchemaError;
85pub use attribute::{AggregateKind, Aggregation, Attribute, Bound};
86#[cfg(feature = "ifc2x3")]
87pub use bundled::ifc2x3;
88#[cfg(feature = "ifc4")]
89pub use bundled::ifc4;
90#[cfg(feature = "ifc4x1")]
91pub use bundled::ifc4x1;
92#[cfg(feature = "ifc4x2")]
93pub use bundled::ifc4x2;
94#[cfg(feature = "ifc4x3")]
95pub use bundled::ifc4x3;
96pub use bundled::{for_version, NotBundled};
97pub use entity::{EntityDef, InverseAttribute, UniqueRule, WhereRule};
98pub use export::{
99    write_direct_structural_catalog, write_structural_catalog, StructuralCatalogSummary,
100};
101pub use registry::Schema;
102pub use types::{TypeDef, TypeKind};
103pub use version::SchemaVersion;