pub trait EntityResolver: Send + Sync {
// Required methods
fn get(&self, id: EntityId) -> Option<Arc<DecodedEntity>>;
fn entities_by_type(&self, ifc_type: &IfcType) -> Vec<Arc<DecodedEntity>>;
fn find_by_type_name(&self, type_name: &str) -> Vec<Arc<DecodedEntity>>;
fn count_by_type(&self, ifc_type: &IfcType) -> usize;
fn all_ids(&self) -> Vec<EntityId>;
fn raw_bytes(&self, id: EntityId) -> Option<&[u8]>;
// Provided methods
fn resolve_ref(&self, attr: &AttributeValue) -> Option<Arc<DecodedEntity>> { ... }
fn resolve_ref_list(&self, attr: &AttributeValue) -> Vec<Arc<DecodedEntity>> { ... }
fn entity_count(&self) -> usize { ... }
}Expand description
Entity lookup and reference resolution
This trait provides the core functionality for accessing IFC entities and resolving entity references. Implementations should provide O(1) lookup by entity ID.
§Example
use bimifc_model::{EntityResolver, EntityId, AttributeValue};
fn process_wall(resolver: &dyn EntityResolver, wall_id: EntityId) {
if let Some(wall) = resolver.get(wall_id) {
println!("Wall type: {:?}", wall.ifc_type);
// Resolve a reference attribute
if let Some(ref_attr) = wall.get(5) {
if let Some(related) = resolver.resolve_ref(ref_attr) {
println!("Related entity: {:?}", related.ifc_type);
}
}
}
}Required Methods§
Sourcefn entities_by_type(&self, ifc_type: &IfcType) -> Vec<Arc<DecodedEntity>>
fn entities_by_type(&self, ifc_type: &IfcType) -> Vec<Arc<DecodedEntity>>
Sourcefn find_by_type_name(&self, type_name: &str) -> Vec<Arc<DecodedEntity>>
fn find_by_type_name(&self, type_name: &str) -> Vec<Arc<DecodedEntity>>
Sourcefn count_by_type(&self, ifc_type: &IfcType) -> usize
fn count_by_type(&self, ifc_type: &IfcType) -> usize
Sourcefn raw_bytes(&self, id: EntityId) -> Option<&[u8]>
fn raw_bytes(&self, id: EntityId) -> Option<&[u8]>
Fast raw bytes access for optimized parsing
Returns the raw bytes of an entity’s definition for parsers that want to do direct parsing without going through the attribute system. This is useful for performance-critical paths like coordinate parsing.
§Arguments
id- The entity ID to get raw bytes for
§Returns
The raw bytes of the entity definition, or None if not available
Provided Methods§
Sourcefn resolve_ref(&self, attr: &AttributeValue) -> Option<Arc<DecodedEntity>>
fn resolve_ref(&self, attr: &AttributeValue) -> Option<Arc<DecodedEntity>>
Resolve an entity reference from an attribute value
If the attribute value is an EntityRef, this looks up and returns the referenced entity.
§Arguments
attr- The attribute value that may contain an entity reference
§Returns
Some(Arc<DecodedEntity>) if the attribute is a valid reference, None otherwise
Sourcefn resolve_ref_list(&self, attr: &AttributeValue) -> Vec<Arc<DecodedEntity>>
fn resolve_ref_list(&self, attr: &AttributeValue) -> Vec<Arc<DecodedEntity>>
Resolve a list of entity references
If the attribute value is a List containing EntityRefs, this resolves all of them and returns the entities.
§Arguments
attr- The attribute value that may contain a list of entity references
§Returns
A vector of resolved entities (empty if the attribute is not a list or contains no refs)
Sourcefn entity_count(&self) -> usize
fn entity_count(&self) -> usize
Get total entity count