Skip to main content

Index

Struct Index 

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

Source

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.

Source

pub fn len(&self) -> usize

Number of records found.

Source

pub fn is_empty(&self) -> bool

Whether the file has no data records.

Source

pub fn header(&self) -> &Header

The file header, as a model read would report it.

Source

pub fn ids(&self) -> impl Iterator<Item = EntityId> + '_

Every id, in file order.

Source

pub fn type_of(&self, id: EntityId) -> Option<&str>

Upper-cased type name of id, without decoding it.

Source

pub fn count_by_type(&self) -> BTreeMap<&str, usize>

How many records of each type. The census a viewer opens with.

Source

pub fn ids_of_type(&self, name: &str) -> Vec<EntityId>

Ids of every record whose type matches name, case-insensitively, in file order.

Source

pub fn entity(&self, id: EntityId) -> Result<Option<Entity>, StepError>

Decodes one record into an Entity: the same parser and IFC conversion a full read uses, on exactly the record’s bytes.

§Errors

When the record is malformed or holds a value the IFC record model cannot represent – exactly what would make a strict read fail.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for Index<'a>

§

impl<'a> RefUnwindSafe for Index<'a>

§

impl<'a> Send for Index<'a>

§

impl<'a> Sync for Index<'a>

§

impl<'a> Unpin for Index<'a>

§

impl<'a> UnsafeUnpin for Index<'a>

§

impl<'a> UnwindSafe for Index<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.