#[non_exhaustive]pub struct EntityDef {
pub name: String,
pub supertypes: Vec<String>,
pub abstract_: bool,
pub attributes: Vec<Attribute>,
pub derived: Vec<String>,
pub redeclared: Vec<Redeclaration>,
pub where_rules: Vec<WhereRule>,
pub inverses: Vec<InverseAttribute>,
pub unique_rules: Vec<UniqueRule>,
}Expand description
One structural entity declaration.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringDeclared entity name.
supertypes: Vec<String>Direct supertypes in SUBTYPE OF order; empty for a root entity.
EXPRESS allows several (SUBTYPE OF (a, b)), and the order is
load-bearing: ISO 10303-21:2016 §12.2.5.2 lays inherited attributes
out supertype by supertype in exactly this order. IFC never uses more
than one; the AP schemas do (AP242: 248 entities).
abstract_: boolWhether the declaration includes ABSTRACT.
attributes: Vec<Attribute>Explicit attributes declared by this entity, excluding derived and inverse declarations.
derived: Vec<String>Names of attributes this entity declares in its DERIVE block.
A subtype may redeclare an inherited explicit attribute as derived:
DERIVE
SELF\IfcGeometricRepresentationContext.Precision : IfcReal
:= NVL(ParentContext.Precision, 1.E-5);The redeclaration keeps the attribute’s inherited position but
removes it from what an instance may state: Part 21 writes such a slot
as *, not as a value and not as $. A consumer that does not know an
attribute is derived cannot tell those apart, so this list is the
minimum needed to write a conforming file.
Names are stored unqualified — the SELF\Entity. prefix is stripped —
because that is how they match the inherited attribute they redeclare.
Entries are in declaration order. Derived attributes that are new
rather than redeclarations appear here too; they occupy no positional
slot, so consumers resolving slots should match against inherited
attribute names rather than assuming every entry is positional.
redeclared: Vec<Redeclaration>Explicit redeclarations of inherited attributes (SELF\X.a : T;).
A redeclaration narrows the type of an inherited attribute; it is not
a new attribute. ISO 10303-21:2016 §12.2.8: it has “no effect on the
encoding” and “shall not be considered an attribute of the subtype for
encoding purposes”. It is therefore kept out of Self::attributes,
which would otherwise grow a positional slot no record contains.
where_rules: Vec<WhereRule>WHERE rules declared by this entity, in declaration order.
Only this entity’s own rules: EXPRESS does not merge a subtype’s rules with its supertype’s, and a consumer checking an instance must walk the supertype chain itself.
inverses: Vec<InverseAttribute>INVERSE attributes declared by this entity, in declaration order.
unique_rules: Vec<UniqueRule>UNIQUE rules declared by this entity, in declaration order.
Implementations§
Source§impl EntityDef
impl EntityDef
Sourcepub fn with_where_rule(self, rule: WhereRule) -> Self
pub fn with_where_rule(self, rule: WhereRule) -> Self
Appends a WHERE rule.
Sourcepub fn with_inverse(self, inverse: InverseAttribute) -> Self
pub fn with_inverse(self, inverse: InverseAttribute) -> Self
Appends an INVERSE attribute.
Sourcepub fn with_unique_rule(self, rule: UniqueRule) -> Self
pub fn with_unique_rule(self, rule: UniqueRule) -> Self
Appends a UNIQUE rule.
Sourcepub fn with_supertype(self, supertype: impl Into<String>) -> Self
pub fn with_supertype(self, supertype: impl Into<String>) -> Self
Appends a direct supertype, after any already declared.
Call once per supertype in SUBTYPE OF order.
Sourcepub fn supertype(&self) -> Option<&str>
pub fn supertype(&self) -> Option<&str>
The first direct supertype, if any.
Sufficient for single-inheritance schemas such as IFC. Code that must
be correct for any EXPRESS schema reads Self::supertypes.
Sourcepub fn with_redeclared(self, redeclaration: Redeclaration) -> Self
pub fn with_redeclared(self, redeclaration: Redeclaration) -> Self
Records an explicit redeclaration of an inherited attribute.
Sourcepub fn with_attribute(self, attribute: Attribute) -> Self
pub fn with_attribute(self, attribute: Attribute) -> Self
Appends an explicit attribute in declaration order.
Sourcepub fn with_derived(self, name: impl Into<String>) -> Self
pub fn with_derived(self, name: impl Into<String>) -> Self
Declares an attribute name as derived, as a DERIVE block would.
Sourcepub fn is_derived(&self, name: &str) -> bool
pub fn is_derived(&self, name: &str) -> bool
Whether name is declared derived by this entity.
Comparison is ASCII case-insensitive: EXPRESS identifiers are case-sensitive in principle, but schema text and Part 21 keywords disagree on case often enough that matching exactly is a foot-gun.
Sourcepub fn is_redeclared(&self, name: &str) -> bool
pub fn is_redeclared(&self, name: &str) -> bool
Whether this entity explicitly redeclares the inherited name.
Case-insensitive, like Self::is_derived.