pub trait StorageSet:
Send
+ Sync
+ 'static {
// Required methods
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>);
// Provided method
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.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.