Trait StorageSet

Source
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§

Source

fn new(desc: ComponentDescriptor, capacity: usize) -> Self

Create a new storage for the given component type T.

Source

fn contains(&self, entity: Entity) -> bool

Returns true if the storage contains a component for the given entity.

Source

fn entity_ids(&self) -> EntityIdSet

Source

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.
Source

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.
Source

fn remove_and_drop(&mut self, entity: Entity)

Removes a component for the given entity.

Source

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.
Source

unsafe fn get_ticks_unchecked(&self, entity: Entity) -> &UnsafeCell<ChangeTicks>

Returns change ticks for the given entity.

§Safety
  • entity must be contained in the storage.
Source

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§

Source

fn get(&self, entity: Entity) -> Option<*mut u8>

Returns a pointer to the component for the given entity.

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.

Implementors§