pub struct EntityTable { /* private fields */ }Expand description
Indirection table mapping EntityId to metadata about stored data.
Implementations§
Source§impl EntityTable
impl EntityTable
Sourcepub fn allocate(
&mut self,
offset: u32,
len: u32,
save_level: u16,
global: bool,
created_after_save: u32,
) -> EntityId
pub fn allocate( &mut self, offset: u32, len: u32, save_level: u16, global: bool, created_after_save: u32, ) -> EntityId
Allocate a new entity, returning its EntityId.
The returned EntityId is tagged with the global bit based on the global param.
Sourcepub fn get(&self, id: EntityId) -> &EntityMeta
pub fn get(&self, id: EntityId) -> &EntityMeta
Get metadata for an entity (read-only).
Sourcepub fn get_mut(&mut self, id: EntityId) -> &mut EntityMeta
pub fn get_mut(&mut self, id: EntityId) -> &mut EntityMeta
Get mutable metadata for an entity.
Sourcepub fn get_by_index(&self, index: usize) -> &EntityMeta
pub fn get_by_index(&self, index: usize) -> &EntityMeta
Get metadata by raw table index, without needing a tagged EntityId.
Callers that sweep the whole table (the VM audit) do not have an
EntityId in hand — they need the metadata in order to build one with
the correct global tag.
Sourcepub fn truncate(&mut self, n: usize)
pub fn truncate(&mut self, n: usize)
Drop every entity from index n onward, so their ids become available
for reuse.
Only sound when no reachable object still refers to those ids. restore
establishes that: PLRM 3.7.3.2 forbids a surviving reference to a
composite created after the save (enforced by check_invalidrestore),
and COW reverts any pre-save composite that was mutated to point at one.
Note that this makes EntityIds reusable. Anything keyed by
EntityId that outlives a restore must be purged in the same step, or a
later entity reusing the index will collide with the stale entry.