Storage

Trait Storage 

Source
pub trait Storage: Sized {
    // Required methods
    fn len(&self) -> usize;
    fn len_mut(&mut self) -> &mut usize;
    fn id(&self) -> StorageId;
    fn empty(id: StorageId) -> EmptyStorage<Self>;
    unsafe fn component<C: Component>(&self) -> &[C];
    unsafe fn component_mut<C: Component>(&self) -> &mut [C];
    fn push_components<C, I>(&mut self, components: I)
       where C: Component,
             I: IntoIterator<Item = C>;
    fn push_component<C: Component>(&mut self, component: C);
    fn contains<C: Component>(&self) -> bool;
    fn types(&self) -> &HashSet<TypeId>;
    fn remove(&mut self, id: ComponentId) -> usize;
}
Expand description

Storage allows to abstract over different types of storages. The most common storage that implements this trait is SoaStorage.

Required Methods§

Source

fn len(&self) -> usize

Source

fn len_mut(&mut self) -> &mut usize

Source

fn id(&self) -> StorageId

Source

fn empty(id: StorageId) -> EmptyStorage<Self>

Creates an EmptyStorage. This storage will not have any registered components when it is created. See RegisterComponent.

Source

unsafe fn component<C: Component>(&self) -> &[C]

Retrieves the component array and panics if C is not inside this storage.

Source

unsafe fn component_mut<C: Component>(&self) -> &mut [C]

Same as Storage::component but mutable.

Source

fn push_components<C, I>(&mut self, components: I)
where C: Component, I: IntoIterator<Item = C>,

Appends components to one array. See AppendComponents that uses this method.

Source

fn push_component<C: Component>(&mut self, component: C)

Source

fn contains<C: Component>(&self) -> bool

Returns true if the Storage has an array of type C.

Source

fn types(&self) -> &HashSet<TypeId>

Source

fn remove(&mut self, id: ComponentId) -> usize

Removes all the components at the specified index.

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§