pub struct Index<'a> { /* private fields */ }Expand description
What is in a file, without what it says.
Borrows the source bytes and stores, per record, its id, span and an
index into a table of distinct type names – about 32 bytes per entity,
two orders of magnitude less than a decoded Model.
Use Index::entity to decode one record, or Index::materialize_closure
to build a real Model from a chosen subset.
Implementations§
Source§impl<'a> Index<'a>
impl<'a> Index<'a>
Sourcepub fn scan(source: &'a [u8]) -> Result<Self, StepError>
pub fn scan(source: &'a [u8]) -> Result<Self, StepError>
Frames every record of source. Does not decode attributes.
§Errors
A header or framing defect: the wrong physical-file marker, a
malformed header, anything between records that is not a record, a
missing ENDSEC, content after the end marker, or an instance id or
type the IFC record model cannot hold (an id beyond u64, a complex
instance). Defects inside a record surface when it is decoded.
Sourcepub fn type_of(&self, id: EntityId) -> Option<&str>
pub fn type_of(&self, id: EntityId) -> Option<&str>
Upper-cased type name of id, without decoding it.
Sourcepub fn count_by_type(&self) -> BTreeMap<&str, usize>
pub fn count_by_type(&self) -> BTreeMap<&str, usize>
How many records of each type. The census a viewer opens with.
Sourcepub fn ids_of_type(&self, name: &str) -> Vec<EntityId>
pub fn ids_of_type(&self, name: &str) -> Vec<EntityId>
Ids of every record whose type matches name, case-insensitively,
in file order.
Sourcepub fn materialize(&self, wanted: &[EntityId]) -> Result<Model, StepError>
pub fn materialize(&self, wanted: &[EntityId]) -> Result<Model, StepError>
Builds a Model from exactly wanted, and nothing else, with the
file’s header. Ids the file does not contain are skipped.
§Dangling references
The result is a real Model but not a self-contained one: an entity
that referenced #7 still says Ref(7) even when #7 was not
requested. Traversal will not resolve it. Use
Index::materialize_closure unless you specifically want the raw
subset and will handle missing targets yourself.
§Errors
The first wanted record that does not decode; see Index::entity.
Sourcepub fn materialize_closure(
&self,
wanted: &[EntityId],
) -> Result<Model, StepError>
pub fn materialize_closure( &self, wanted: &[EntityId], ) -> Result<Model, StepError>
Builds a Model containing wanted and everything they reach.
Follows references transitively, so the result has no dangling Ref
except to ids the file itself does not define. This is the
constructor to reach for: it is what makes a subset independently
usable.
§Errors
The first reached record that does not decode; see Index::entity.