pub struct PropertyIndex<'m> { /* private fields */ }Expand description
The exact resolver’s view of one model, scanned once for many queries.
Answers exactly what the free functions answer, results and errors
alike: Self::exact_property is exact_property,
Self::exact_properties is exact_properties,
and so on, for every object of the model. The difference is cost. A free
function validates every property relationship in the file on each
call; the index validates them once, in Self::build, and records the
sets each object is assigned. A loop resolving every object is then
linear in objects plus relationships instead of their product.
let index = PropertyIndex::build(model);
for &object in objects {
assert_eq!(
index.exact_property(object, Some("Pset_WallCommon"), "IsExternal"),
exact_property(model, object, Some("Pset_WallCommon"), "IsExternal"),
);
}§It cannot go stale
The index is a borrowed view (ADR 0003): it holds &Model for its
whole life, so the model cannot be mutated, by a
Transaction or otherwise, while the index
exists. To read after an edit, drop the index, commit, and build a new
one from the edited model.
§Refusals
A model the exact resolver refuses as a whole (diagnostics, no or several schemas, an unsupported release) still builds; every query then returns that refusal, as every free function would. A malformed relationship is likewise reported by each query it would have refused.
Implementations§
Source§impl<'m> PropertyIndex<'m>
impl<'m> PropertyIndex<'m>
Sourcepub fn build(model: &'m Model) -> Self
pub fn build(model: &'m Model) -> Self
Bind model to its declared release and validate every property
relationship once.
Linear in the model’s IfcRelDefinesByProperties and
IfcRelDefinesByType and the objects they relate. Never fails: a
refusal is kept and returned by every query.
Sourcepub fn schema(&self) -> Result<SchemaVersion, ExactPropertyError>
pub fn schema(&self) -> Result<SchemaVersion, ExactPropertyError>
The release every query resolves against, as
exact_schema answers.
§Errors
The model-level refusal exact_schema returns.
Sourcepub fn exact_property(
&self,
object: EntityId,
set_name: Option<&str>,
property_name: &str,
) -> Result<ExactResolution, ExactPropertyError>
pub fn exact_property( &self, object: EntityId, set_name: Option<&str>, property_name: &str, ) -> Result<ExactResolution, ExactPropertyError>
Sourcepub fn exact_properties(
&self,
object: EntityId,
) -> Result<Vec<ExactPropertyEntry>, ExactPropertyError>
pub fn exact_properties( &self, object: EntityId, ) -> Result<Vec<ExactPropertyEntry>, ExactPropertyError>
Sourcepub fn exact_properties_where<S, P>(
&self,
object: EntityId,
select_set: S,
select_property: P,
) -> Result<Vec<ExactPropertyEntry>, ExactPropertyError>
pub fn exact_properties_where<S, P>( &self, object: EntityId, select_set: S, select_property: P, ) -> Result<Vec<ExactPropertyEntry>, ExactPropertyError>
Sourcepub fn exact_property_sets_where<S>(
&self,
object: EntityId,
select_set: S,
) -> Result<Vec<ExactPropertySetEntry>, ExactPropertyError>
pub fn exact_property_sets_where<S>( &self, object: EntityId, select_set: S, ) -> Result<Vec<ExactPropertySetEntry>, ExactPropertyError>
Sourcepub fn exact_predefined_sets(
&self,
object: EntityId,
entity: &str,
) -> Result<Vec<ExactPredefinedSet>, ExactPropertyError>
pub fn exact_predefined_sets( &self, object: EntityId, entity: &str, ) -> Result<Vec<ExactPredefinedSet>, ExactPropertyError>
Trait Implementations§
Source§impl<'m> Clone for PropertyIndex<'m>
impl<'m> Clone for PropertyIndex<'m>
Source§fn clone(&self) -> PropertyIndex<'m>
fn clone(&self) -> PropertyIndex<'m>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more