[−][src]Trait goggles::component::RawStorage
A trait for storing components in memory based on low valued indexes.
Is not required to keep track of whether the component is present or not for a given index, it
is up to the user of a RawStorage
to keep track of this.
Because of this, a type that implements RawStorage
is allowed to leak all component values
on drop. In order to prevent this, the storage must have only empty indexes at the time of
drop.
Required methods
unsafe fn get(&self, index: Index) -> &C
Return a reference to the component at the given index.
You must only call get
with index values that are non-empty (have been previously had
components inserted with insert
).
unsafe fn get_mut(&self, index: Index) -> &mut C
Return a mutable reference to the component at the given index.
You must only call get_mut
with index values that are non-empty (have been previously
had components inserted with insert
).
Returns a mutable reference to the previously inserted component. You must follow Rust's aliasing rules here, so you must not call this method if there is any other live reference to the same component.
unsafe fn insert(&mut self, index: Index, value: C)
Insert a new component value in the given index.
You must only call insert
on indexes that are empty. All indexes start empty, but become
non-empty once insert
is called on them.
unsafe fn remove(&mut self, index: Index) -> C
Remove a component previously inserted in the given index.
You must only call remove
on a non-empty index (after you have inserted a value with
insert
). After calling remove
the index becomes empty.
Implementors
impl<C> RawStorage<C> for DenseVecStorage<C>
[src]
unsafe fn get(&self, index: Index) -> &C
[src]
unsafe fn get_mut(&self, index: Index) -> &mut C
[src]
unsafe fn insert(&mut self, index: Index, c: C)
[src]
unsafe fn remove(&mut self, index: Index) -> C
[src]
impl<C> RawStorage<C> for HashMapStorage<C>
[src]
unsafe fn get(&self, index: Index) -> &C
[src]
unsafe fn get_mut(&self, index: Index) -> &mut C
[src]
unsafe fn insert(&mut self, index: Index, v: C)
[src]
unsafe fn remove(&mut self, index: Index) -> C
[src]
impl<C> RawStorage<C> for VecStorage<C>
[src]
unsafe fn get(&self, index: Index) -> &C
[src]
unsafe fn get_mut(&self, index: Index) -> &mut C
[src]
unsafe fn insert(&mut self, index: Index, c: C)
[src]
unsafe fn remove(&mut self, index: Index) -> C
[src]
impl<C, S> RawStorage<C> for Flagged<S> where
C: Component,
S: RawStorage<C>,
[src]
C: Component,
S: RawStorage<C>,