Trait specs::UnprotectedStorage
[−]
[src]
pub trait UnprotectedStorage<T>: Sized { fn new() -> Self; unsafe fn clean<F>(&mut self, _: F) where F: Fn(Index) -> bool; unsafe fn get(&self, id: Index) -> &T; unsafe fn get_mut(&mut self, id: Index) -> &mut T; unsafe fn insert(&mut self, _: Index, _: T); unsafe fn remove(&mut self, _: Index) -> T; }
Used by the framework to quickly join componets
Required Methods
fn new() -> Self
Creates a new Storage<T>
. This is called when you register a new
component type within the world.
unsafe fn clean<F>(&mut self, _: F) where F: Fn(Index) -> bool
Clean the storage given a check to figure out if an index is valid or not. Allows us to safely drop the storage.
unsafe fn get(&self, id: Index) -> &T
Tries reading the data associated with an Index
.
This is unsafe because the external set used
to protect this storage is absent.
unsafe fn get_mut(&mut self, id: Index) -> &mut T
Tries mutating the data associated with an Index
.
This is unsafe because the external set used
to protect this storage is absent.
unsafe fn insert(&mut self, _: Index, _: T)
Inserts new data for a given Index
.
unsafe fn remove(&mut self, _: Index) -> T
Removes the data associated with an Index
.
Implementors
impl<T> UnprotectedStorage<T> for HashMapStorage<T>
impl<T> UnprotectedStorage<T> for VecStorage<T>
impl<T: Default> UnprotectedStorage<T> for NullStorage<T>