pub struct Schema { /* private fields */ }Expand description
An IFC schema: the entity and type tables, queryable.
Every lookup folds ASCII case: Part 21 spells IFCWALL, the schema
IfcWall, and either may be passed.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn new(
name: impl Into<String>,
entities: Vec<EntityDef>,
types: Vec<TypeDef>,
) -> Self
pub fn new( name: impl Into<String>, entities: Vec<EntityDef>, types: Vec<TypeDef>, ) -> Self
Assembles a schema from declarations in source order.
A name declared more than once keeps its first position and its last declaration, so counts are of distinct names.
Sourcepub fn from_express(source: &str) -> Self
pub fn from_express(source: &str) -> Self
Parses EXPRESS source into a schema.
Requires the express feature, which links the openbim-step
EXPRESS extractor. Its result is converted into this crate’s own
types; explicit attribute redeclarations are not recorded.
Sourcepub fn from_express_bytes(bytes: &[u8]) -> Self
pub fn from_express_bytes(bytes: &[u8]) -> Self
Parses EXPRESS source that is not valid UTF-8.
The normative IFC4.exp is Latin-1: it contains ° and similar in
comments. Decoding byte-per-char is correct for the ASCII structure
this parser reads and cannot fail. Requires the express feature.
Sourcepub fn version(&self) -> Option<SchemaVersion>
pub fn version(&self) -> Option<SchemaVersion>
The IFC schema version this table describes, when recognized.
This is the one genuinely IFC-specific query on this type: it maps a declared schema name onto the versions this crate knows about.
Sourcepub fn entity_count(&self) -> usize
pub fn entity_count(&self) -> usize
How many entity declarations the schema holds.
Sourcepub fn type_count(&self) -> usize
pub fn type_count(&self) -> usize
How many type declarations the schema holds.
Sourcepub fn entity(&self, name: &str) -> Option<&EntityDef>
pub fn entity(&self, name: &str) -> Option<&EntityDef>
The entity declaration for name, if the schema declares one.
Sourcepub fn type_def(&self, name: &str) -> Option<&TypeDef>
pub fn type_def(&self, name: &str) -> Option<&TypeDef>
The type declaration for name, if the schema declares one.
Sourcepub fn entities(&self) -> impl Iterator<Item = &EntityDef>
pub fn entities(&self) -> impl Iterator<Item = &EntityDef>
Every entity declaration, in source order.
Sourcepub fn entity_names(&self) -> impl Iterator<Item = &str>
pub fn entity_names(&self) -> impl Iterator<Item = &str>
Every entity name the schema declares.
Source order today; callers needing a particular order must sort.
Sourcepub fn accepts_type(&self, declared: &str, candidate: &str) -> bool
pub fn accepts_type(&self, declared: &str, candidate: &str) -> bool
Whether a candidate entity or defined type satisfies a declared type.
This walks entity inheritance, defined-type aliases, and nested SELECTs. Unknown declarations and cyclic aliases fail closed.
Sourcepub fn is_a(&self, name: &str, ancestor: &str) -> bool
pub fn is_a(&self, name: &str, ancestor: &str) -> bool
Whether name is ancestor, or inherits from it.
Reflexive for declared entities. An entity the schema never declares is not a subtype of anything, including itself – otherwise a typo would silently satisfy every check made against it.
Sourcepub fn supertypes(&self, name: &str) -> Vec<&str>
pub fn supertypes(&self, name: &str) -> Vec<&str>
The supertype chain above name, nearest parent first.
Depth-first in SUBTYPE OF order, each ancestor once, excluding
name. A supertype the schema names but never declares is reported
but cannot be walked past. Terminates on a malformed cyclic schema.
Sourcepub fn direct_subtypes(&self, name: &str) -> Vec<&str>
pub fn direct_subtypes(&self, name: &str) -> Vec<&str>
Entities declaring SUBTYPE OF (name) directly, sorted by name.
Sourcepub fn subtypes(&self, name: &str) -> Vec<&str>
pub fn subtypes(&self, name: &str) -> Vec<&str>
Every entity inheriting from name at any depth, excluding name.
Sorted depth-first pre-order. The inverse of Self::is_a.
Sourcepub fn attributes(&self, name: &str) -> Vec<&Attribute>
pub fn attributes(&self, name: &str) -> Vec<&Attribute>
Every attribute slot in Part 21 positional order, inherited first.
ISO 10303-21:2016 §12.2.5.2: each supertype is laid out in
SUBTYPE OF order, its own supertypes first, and a supertype reached
a second time contributes nothing more. Derived redeclarations are
included (they keep their slot and are written *); use
EntityDef::is_derived on the owning entity to tell them apart.
Sourcepub fn attribute_count(&self, name: &str) -> usize
pub fn attribute_count(&self, name: &str) -> usize
How many positional slots Self::attributes lists for name;
0 for an entity the schema does not declare.
Read from the precomputed layout, without allocating.
Sourcepub fn attribute_at(&self, name: &str, slot: usize) -> Option<&Attribute>
pub fn attribute_at(&self, name: &str, slot: usize) -> Option<&Attribute>
The attribute at positional slot of name, as
attributes(name).get(slot) answers, without allocating.
Sourcepub fn attribute_names(&self, name: &str) -> Vec<&str>
pub fn attribute_names(&self, name: &str) -> Vec<&str>
Attribute names in positional order.
Sourcepub fn resolve_defined(&self, name: &str) -> String
pub fn resolve_defined(&self, name: &str) -> String
Resolves a defined type to the base it ultimately aliases.
IfcPositiveLengthMeasure -> IfcLengthMeasure -> REAL. Returns
the final right-hand side verbatim (including any aggregate syntax);
for a declaration that is not an alias, the type’s own name. Bounded
so a cyclic alias cannot hang.