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§
fn len(&self) -> usize
fn len_mut(&mut self) -> &mut usize
fn id(&self) -> StorageId
Sourcefn empty(id: StorageId) -> EmptyStorage<Self>
fn empty(id: StorageId) -> EmptyStorage<Self>
Creates an EmptyStorage. This storage will not have any registered components when it
is created. See RegisterComponent.
Sourceunsafe fn component<C: Component>(&self) -> &[C]
unsafe fn component<C: Component>(&self) -> &[C]
Retrieves the component array and panics if C is not inside this storage.
Sourceunsafe fn component_mut<C: Component>(&self) -> &mut [C]
unsafe fn component_mut<C: Component>(&self) -> &mut [C]
Same as Storage::component but mutable.
Sourcefn push_components<C, I>(&mut self, components: I)where
C: Component,
I: IntoIterator<Item = C>,
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.
fn push_component<C: Component>(&mut self, component: C)
fn types(&self) -> &HashSet<TypeId>
Sourcefn remove(&mut self, id: ComponentId) -> usize
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.