Skip to main content

PropertyIndex

Struct PropertyIndex 

Source
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>

Source

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.

Source

pub fn model(&self) -> &'m Model

The model this index was built from.

Source

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.

Source

pub fn exact_property( &self, object: EntityId, set_name: Option<&str>, property_name: &str, ) -> Result<ExactResolution, ExactPropertyError>

exact_property of object.

§Errors

As for exact_property.

Source

pub fn exact_properties( &self, object: EntityId, ) -> Result<Vec<ExactPropertyEntry>, ExactPropertyError>

exact_properties of object.

§Errors

As for exact_properties.

Source

pub fn exact_properties_where<S, P>( &self, object: EntityId, select_set: S, select_property: P, ) -> Result<Vec<ExactPropertyEntry>, ExactPropertyError>
where S: FnMut(&str) -> bool, P: FnMut(&str) -> bool,

Source

pub fn exact_property_sets_where<S>( &self, object: EntityId, select_set: S, ) -> Result<Vec<ExactPropertySetEntry>, ExactPropertyError>
where S: FnMut(&str) -> bool,

Source

pub fn exact_predefined_sets( &self, object: EntityId, entity: &str, ) -> Result<Vec<ExactPredefinedSet>, ExactPropertyError>

Trait Implementations§

Source§

impl<'m> Clone for PropertyIndex<'m>

Source§

fn clone(&self) -> PropertyIndex<'m>

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 PropertyIndex<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'m> !RefUnwindSafe for PropertyIndex<'m>

§

impl<'m> !UnwindSafe for PropertyIndex<'m>

§

impl<'m> Freeze for PropertyIndex<'m>

§

impl<'m> Send for PropertyIndex<'m>

§

impl<'m> Sync for PropertyIndex<'m>

§

impl<'m> Unpin for PropertyIndex<'m>

§

impl<'m> UnsafeUnpin for PropertyIndex<'m>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.