Struct genesis::MapStorage [−][src]
A storage type based on a HashMap, intended for sparsely used components.
Implementations
impl<T> MapStorage<T>[src]
pub fn new(entity_allocator: Arc<RwLock<Entities>>) -> Self[src]
Create a new MapStorage
pub fn get(&self, entity: Entity) -> Option<&T>[src]
Get a reference to the associated component for the given entity, if any.
pub fn get_mut(&mut self, entity: Entity) -> Option<&mut T>[src]
Get a mutable reference to the associated component for the given entity, if any.
pub fn set(
&mut self,
entity: Entity,
data: T
) -> Result<Option<T>, NoSuchEntity>[src]
&mut self,
entity: Entity,
data: T
) -> Result<Option<T>, NoSuchEntity>
Set the component for the given entity. Returns Err(NoSuchEnitty) if the given entity doesn’t exist. Otherwise, returns the previous data stored in self for the given entity.
pub fn remove_unchecked(&mut self, entity: Entity) -> Option<T>[src]
Remove the component for the given entity. Returns the previous data associated with the given entity in self. Does not check if the entity exists; only use this if you know it exists, e.g. through invariants in your code or because you retrieved this in a loop iterating over all alive entities.
pub fn remove(&mut self, entity: Entity) -> Result<Option<T>, NoSuchEntity>[src]
Remove the component for the given entity. Returns the previous data associated with the given entity in self.
pub fn clear(&mut self)[src]
Remove the data stored in self for all entities.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for MapStorage<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for MapStorage<T> where
T: Send,
T: Send,
impl<T> Sync for MapStorage<T> where
T: Sync,
T: Sync,
impl<T> Unpin for MapStorage<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for MapStorage<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,