Skip to main content

EntityDef

Struct EntityDef 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: String

Declared 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_: bool

Whether 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

Source

pub fn new(name: impl Into<String>) -> Self

Creates an empty concrete entity declaration.

Source

pub const fn abstract_(self) -> Self

Marks the entity ABSTRACT.

Source

pub fn with_where_rule(self, rule: WhereRule) -> Self

Appends a WHERE rule.

Source

pub fn with_inverse(self, inverse: InverseAttribute) -> Self

Appends an INVERSE attribute.

Source

pub fn with_unique_rule(self, rule: UniqueRule) -> Self

Appends a UNIQUE rule.

Source

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.

Source

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.

Source

pub fn with_redeclared(self, redeclaration: Redeclaration) -> Self

Records an explicit redeclaration of an inherited attribute.

Source

pub fn with_attribute(self, attribute: Attribute) -> Self

Appends an explicit attribute in declaration order.

Source

pub fn with_derived(self, name: impl Into<String>) -> Self

Declares an attribute name as derived, as a DERIVE block would.

Source

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.

Source

pub fn is_redeclared(&self, name: &str) -> bool

Whether this entity explicitly redeclares the inherited name.

Case-insensitive, like Self::is_derived.

Trait Implementations§

Source§

impl Clone for EntityDef

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EntityDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for EntityDef

Source§

impl PartialEq for EntityDef

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EntityDef

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.