Trait specs::Storage
[−]
[src]
pub trait Storage<T>: StorageBase + Sized { type UnprotectedStorage: UnprotectedStorage<T>; fn new() -> Self; fn insert(&mut self, Entity, T); fn get(&self, Entity) -> Option<&T>; fn get_mut(&mut self, Entity) -> Option<&mut T>; fn remove(&mut self, Entity) -> Option<T>; fn open(&self) -> (&BitSet, &Self::UnprotectedStorage); fn open_mut(&mut self) -> (&BitSet, &mut Self::UnprotectedStorage); }
Typed component storage trait.
Associated Types
type UnprotectedStorage: UnprotectedStorage<T>
Used during iterator
Required Methods
fn new() -> Self
Creates a new Storage<T>
. This is called when you register a new
component type within the world.
fn insert(&mut self, Entity, T)
Inserts new data for a given Entity
.
fn get(&self, Entity) -> Option<&T>
Tries to read the data associated with an Entity
.
fn get_mut(&mut self, Entity) -> Option<&mut T>
Tries to mutate the data associated with an Entity
.
fn remove(&mut self, Entity) -> Option<T>
Removes the data associated with an Entity
.
fn open(&self) -> (&BitSet, &Self::UnprotectedStorage)
Splits the BitSet
from the storage for use
by the Join
iterator.
fn open_mut(&mut self) -> (&BitSet, &mut Self::UnprotectedStorage)
Splits the BitSet
mutably from the storage for use
by the Join
iterator.
Implementors
impl<T> Storage<T> for HashMapStorage<T>
impl<T> Storage<T> for VecStorage<T>