[][src]Trait goggles::storage::RawStorage

pub trait RawStorage {
    type Item;
    unsafe fn get(&self, index: Index) -> &Self::Item;
unsafe fn get_mut(&self, index: Index) -> &mut Self::Item;
unsafe fn insert(&mut self, index: Index, value: Self::Item);
unsafe fn remove(&mut self, index: Index) -> Self::Item; }

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.

Associated Types

type Item

Loading content...

Required methods

unsafe fn get(&self, index: Index) -> &Self::Item

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 Self::Item

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: Self::Item)

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) -> Self::Item

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.

Loading content...

Implementors

impl<S> RawStorage for Flagged<S> where
    S: RawStorage
[src]

type Item = S::Item

impl<T> RawStorage for DenseVecStorage<T>[src]

type Item = T

impl<T> RawStorage for HashMapStorage<T>[src]

type Item = T

impl<T> RawStorage for VecStorage<T>[src]

type Item = T

Loading content...