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

Create a new storage. This is called when you register a new component type within the world.

fn insert(&mut self, Entity, T)

Insert a new data for a given entity.

fn get(&self, Entity) -> Option<&T>

Try reading the data associated with an entity.

fn get_mut(&mut self, Entity) -> Option<&mut T>

Try mutating the data associated with an entity.

fn remove(&mut self, Entity) -> Option<T>

Remove 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 from the storage for use by the join iterator.

Implementors