Trait termite::StorageSet
source · pub trait StorageSet: Send + Sync + 'static {
fn new(desc: ComponentDescriptor, capacity: usize) -> Self;
fn contains(&self, entity: Entity) -> bool;
fn entity_ids(&self) -> EntityIdSet;
unsafe fn insert(
&mut self,
entity: Entity,
component: *mut u8,
change_ticks: u32
);
unsafe fn remove_unchecked(&mut self, entity: Entity, component: *mut u8);
fn remove_and_drop(&mut self, entity: Entity);
unsafe fn get_unchecked(&self, entity: Entity) -> *mut u8;
unsafe fn get_ticks_unchecked(
&self,
entity: Entity
) -> &UnsafeCell<ChangeTicks>;
unsafe fn get_with_ticks_unchecked(
&self,
entity: Entity
) -> (*mut u8, &UnsafeCell<ChangeTicks>);
fn get(&self, entity: Entity) -> Option<*mut u8> { ... }
}
Required Methods
sourcefn new(desc: ComponentDescriptor, capacity: usize) -> Self
fn new(desc: ComponentDescriptor, capacity: usize) -> Self
Create a new storage for the given component type T
.
sourcefn contains(&self, entity: Entity) -> bool
fn contains(&self, entity: Entity) -> bool
Returns true
if the storage contains a component for the given entity.
fn entity_ids(&self) -> EntityIdSet
sourceunsafe fn insert(&mut self, entity: Entity, component: *mut u8, change_ticks: u32)
unsafe fn insert(&mut self, entity: Entity, component: *mut u8, change_ticks: u32)
Inserts a component for the given entity.
Safety
- The storage must be able to store components of type
T
.
sourceunsafe fn remove_unchecked(&mut self, entity: Entity, component: *mut u8)
unsafe fn remove_unchecked(&mut self, entity: Entity, component: *mut u8)
Removes a component for the given entity.
Safety
entity
must be contained in the storage.component
must be a valid pointer.
sourcefn remove_and_drop(&mut self, entity: Entity)
fn remove_and_drop(&mut self, entity: Entity)
Removes a component for the given entity.
sourceunsafe fn get_unchecked(&self, entity: Entity) -> *mut u8
unsafe fn get_unchecked(&self, entity: Entity) -> *mut u8
Returns a pointer to the component for the given entity.
Safety
entity
must be contained in the storage.
sourceunsafe fn get_ticks_unchecked(&self, entity: Entity) -> &UnsafeCell<ChangeTicks>
unsafe fn get_ticks_unchecked(&self, entity: Entity) -> &UnsafeCell<ChangeTicks>
sourceunsafe fn get_with_ticks_unchecked(
&self,
entity: Entity
) -> (*mut u8, &UnsafeCell<ChangeTicks>)
unsafe fn get_with_ticks_unchecked(
&self,
entity: Entity
) -> (*mut u8, &UnsafeCell<ChangeTicks>)
Returns a pointer to the component for the given entity and it’s change ticks.
Safety
entity
must be contained in the storage.