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
Sourcepub fn write_binary<W: Write>(&self, w: W) -> Result<()>
pub fn write_binary<W: Write>(&self, w: W) -> Result<()>
Writes the binary form (see the module doc). Pass a buffered writer: the columns go out in many small writes.
Sourcepub fn read_binary<R: Read>(r: R) -> Result<Model>
pub fn read_binary<R: Read>(r: R) -> Result<Model>
Reads a model written by Model::write_binary, checking its
indexes. Pass a buffered reader.
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 Modelwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<LanguageId>: Freeze,
PhantomData<KindInfo>: Freeze,
PhantomData<RelationKind>: Freeze,
PhantomData<EntityRow>: Freeze,
PhantomData<(EntityId, BTreeMap<String, Value>)>: Freeze,
PhantomData<EntityId>: Freeze,
PhantomData<u32>: Freeze,
PhantomData<RelRow>: Freeze,
PhantomData<Range>: Freeze,
PhantomData<SiteFlags>: Freeze,
impl Move for Model
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnsafeUnpin for Modelwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<LanguageId>: UnsafeUnpin,
PhantomData<KindInfo>: UnsafeUnpin,
PhantomData<RelationKind>: UnsafeUnpin,
PhantomData<EntityRow>: UnsafeUnpin,
PhantomData<(EntityId, BTreeMap<String, Value>)>: UnsafeUnpin,
PhantomData<EntityId>: UnsafeUnpin,
PhantomData<u32>: UnsafeUnpin,
PhantomData<RelRow>: UnsafeUnpin,
PhantomData<Range>: UnsafeUnpin,
PhantomData<SiteFlags>: UnsafeUnpin,
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