pub struct Model { /* private fields */ }Expand description
Frozen, compact model.
Layout, chosen to keep every occurrence affordable:
- strings (keys, names, files) interned once in a single buffer;
- fixed-size entity rows, sparse props;
- relations deduplicated and sorted by source, so the outgoing relations of an entity are one slice (CSR); incoming ones are an index array;
- occurrence sites stored as 16-byte ranges plus a 1-byte flags column (17 bytes/site), grouped by relation (CSR); their file is the file of the relation’s source entity.
Implementations§
Source§impl Model
impl Model
pub fn entity_count(&self) -> usize
pub fn relation_count(&self) -> usize
pub fn site_count(&self) -> usize
pub fn entity(&self, id: EntityId) -> Option<EntityRef<'_>>
pub fn by_key(&self, key: &str) -> Option<EntityRef<'_>>
pub fn entities(&self) -> impl ExactSizeIterator<Item = EntityRef<'_>>
Sourcepub fn of_kind(&self, kind: EntityKind) -> impl Iterator<Item = EntityRef<'_>>
pub fn of_kind(&self, kind: EntityKind) -> impl Iterator<Item = EntityRef<'_>>
Entities of an archetype, whatever their fine kind.
Sourcepub fn of_kind_id(&self, kind: KindId) -> impl Iterator<Item = EntityRef<'_>>
pub fn of_kind_id(&self, kind: KindId) -> impl Iterator<Item = EntityRef<'_>>
Entities of exactly this fine kind.
Sourcepub fn of_trait(&self, traits: TraitMask) -> impl Iterator<Item = EntityRef<'_>>
pub fn of_trait(&self, traits: TraitMask) -> impl Iterator<Item = EntityRef<'_>>
Entities whose kind carries every trait of traits. Bit meanings are
defined by the metamodel’s author (see the model-traits crate).
Sourcepub fn metamodel(&self) -> &Metamodel
pub fn metamodel(&self) -> &Metamodel
Kinds of this model: archetype, traits and FM3 class of each.
pub fn roots(&self) -> impl Iterator<Item = EntityRef<'_>>
pub fn relation(&self, id: RelationId) -> Option<RelationRef<'_>>
pub fn relations(&self) -> impl ExactSizeIterator<Item = RelationRef<'_>>
Sourcepub fn languages(&self) -> &[LanguageId]
pub fn languages(&self) -> &[LanguageId]
Languages present, in first-seen order.
pub fn memory(&self) -> MemoryStats
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Model
impl<'de> Deserialize<'de> for Model
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Forget for Model
impl Freeze for Model
impl Move for Model
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnsafeUnpin for Model
impl UnwindSafe for Model
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more