Trait constellation::ComponentResourceApi
[−]
[src]
pub trait ComponentResourceApi { type Component; fn get(&self, _: Entity) -> Option<&Self::Component>; fn get_mut(&mut self, _: Entity) -> Option<&mut Self::Component>; unsafe fn get_unchecked(&self, entity: Entity) -> &Self::Component; unsafe fn get_unchecked_mut(
&mut self,
entity: Entity
) -> &mut Self::Component; }
A component resource is a resource which stores data related to entities
in the form of a single Self::Component
per entity.
Associated Types
type Component
The type of data stored for each entity.
Required Methods
fn get(&self, _: Entity) -> Option<&Self::Component>
Gets a shared reference to the component associated with the given entity, if present.
fn get_mut(&mut self, _: Entity) -> Option<&mut Self::Component>
Gets a mutable reference to the component associated with the given entity, if present.
unsafe fn get_unchecked(&self, entity: Entity) -> &Self::Component
Gets a shared reference to the component associated with the given entity without performing any bounds or liveness checking.
Safety
This function performs no bounds checking. Requesting data for an entity that does not represent a living entity with data in this resource will return an undefined result.
unsafe fn get_unchecked_mut(&mut self, entity: Entity) -> &mut Self::Component
Gets a mutable reference to the component associated with the given entity without performing any bounds or liveness checking.
Safety
This function performs no bounds checking. Requesting data for an entity that does not represent a living entity with data in this resource will return an undefined result.
Implementors
impl<T> ComponentResourceApi for MapStorage<T>
impl<T> ComponentResourceApi for VecStorage<T>