Struct specs::storage::Storage [−][src]
pub struct Storage<'e, T, D> { /* fields omitted */ }
A wrapper around the masked storage and the generations vector.
Can be used for safe lookup of components, insertions and removes.
This is what World::read/write
fetches for the user.
Methods
impl<'st, T, D> Storage<'st, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
[src]
impl<'st, T, D> Storage<'st, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
pub fn restrict<'rf>(
&'rf self
) -> RestrictedStorage<'rf, 'st, T, &T::Storage, &BitSet, ImmutableParallelRestriction>
[src]
pub fn restrict<'rf>(
&'rf self
) -> RestrictedStorage<'rf, 'st, T, &T::Storage, &BitSet, ImmutableParallelRestriction>
Builds an immutable RestrictedStorage
out of a Storage
. Allows deferred
unchecked access to the entity's component.
This is returned as a ParallelRestriction
version since you can only get
immutable components with this which is safe for parallel by default.
impl<'st, T, D> Storage<'st, T, D> where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
[src]
impl<'st, T, D> Storage<'st, T, D> where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
pub fn restrict_mut<'rf>(
&'rf mut self
) -> RestrictedStorage<'rf, 'st, T, &mut T::Storage, &BitSet, SequentialRestriction>
[src]
pub fn restrict_mut<'rf>(
&'rf mut self
) -> RestrictedStorage<'rf, 'st, T, &mut T::Storage, &BitSet, SequentialRestriction>
Builds a mutable RestrictedStorage
out of a Storage
. Allows restricted
access to the inner components without allowing invalidating the
bitset for iteration in Join
.
pub fn par_restrict_mut<'rf>(
&'rf mut self
) -> RestrictedStorage<'rf, 'st, T, &mut T::Storage, &BitSet, MutableParallelRestriction>
[src]
pub fn par_restrict_mut<'rf>(
&'rf mut self
) -> RestrictedStorage<'rf, 'st, T, &mut T::Storage, &BitSet, MutableParallelRestriction>
Builds a mutable, parallel RestrictedStorage
,
does not allow mutably getting other components
aside from the current iteration.
impl<'e, T, D> Storage<'e, T, D> where
T: Component,
T::Storage: Tracked,
D: Deref<Target = MaskedStorage<T>>,
[src]
impl<'e, T, D> Storage<'e, T, D> where
T: Component,
T::Storage: Tracked,
D: Deref<Target = MaskedStorage<T>>,
pub fn channels(&self) -> &TrackChannels
[src]
pub fn channels(&self) -> &TrackChannels
Returns the event channel tracking modified components.
pub fn modified(&self) -> &EventChannel<ModifiedFlag>
[src]
pub fn modified(&self) -> &EventChannel<ModifiedFlag>
Returns the event channel tracking modified components.
pub fn inserted(&self) -> &EventChannel<InsertedFlag>
[src]
pub fn inserted(&self) -> &EventChannel<InsertedFlag>
Returns the event channel tracking inserted components.
pub fn removed(&self) -> &EventChannel<RemovedFlag>
[src]
pub fn removed(&self) -> &EventChannel<RemovedFlag>
Returns the event channel tracking removed components.
pub fn populate_modified<E>(
&self,
reader_id: &mut ReaderId<ModifiedFlag>,
value: &mut E
) where
E: Extend<Index>,
[src]
pub fn populate_modified<E>(
&self,
reader_id: &mut ReaderId<ModifiedFlag>,
value: &mut E
) where
E: Extend<Index>,
Reads events from the modified EventChannel
and populates a structure using the events.
pub fn populate_inserted<E>(
&self,
reader_id: &mut ReaderId<InsertedFlag>,
value: &mut E
) where
E: Extend<Index>,
[src]
pub fn populate_inserted<E>(
&self,
reader_id: &mut ReaderId<InsertedFlag>,
value: &mut E
) where
E: Extend<Index>,
Reads events from the inserted EventChannel
and populates a structure using the events.
pub fn populate_removed<E>(
&self,
reader_id: &mut ReaderId<RemovedFlag>,
value: &mut E
) where
E: Extend<Index>,
[src]
pub fn populate_removed<E>(
&self,
reader_id: &mut ReaderId<RemovedFlag>,
value: &mut E
) where
E: Extend<Index>,
Reads events from the removed EventChannel
and populates a structure using the events.
impl<'e, T, D> Storage<'e, T, D> where
T: Component,
T::Storage: Tracked,
D: DerefMut<Target = MaskedStorage<T>>,
[src]
impl<'e, T, D> Storage<'e, T, D> where
T: Component,
T::Storage: Tracked,
D: DerefMut<Target = MaskedStorage<T>>,
pub fn channels_mut(&mut self) -> &mut TrackChannels
[src]
pub fn channels_mut(&mut self) -> &mut TrackChannels
Returns all of the event channels for this component.
pub fn modified_mut(&mut self) -> &mut EventChannel<ModifiedFlag>
[src]
pub fn modified_mut(&mut self) -> &mut EventChannel<ModifiedFlag>
Returns the event channel tracking modified components mutably.
pub fn inserted_mut(&mut self) -> &mut EventChannel<InsertedFlag>
[src]
pub fn inserted_mut(&mut self) -> &mut EventChannel<InsertedFlag>
Returns the event channel tracking inserted components mutably.
pub fn removed_mut(&mut self) -> &mut EventChannel<RemovedFlag>
[src]
pub fn removed_mut(&mut self) -> &mut EventChannel<RemovedFlag>
Returns the event channel tracking removed components mutably.
pub fn track_modified(&mut self) -> ReaderId<ModifiedFlag>
[src]
pub fn track_modified(&mut self) -> ReaderId<ModifiedFlag>
Starts tracking modified events.
pub fn track_inserted(&mut self) -> ReaderId<InsertedFlag>
[src]
pub fn track_inserted(&mut self) -> ReaderId<InsertedFlag>
Starts tracking inserted events.
pub fn track_removed(&mut self) -> ReaderId<RemovedFlag>
[src]
pub fn track_removed(&mut self) -> ReaderId<RemovedFlag>
Starts tracking removed events.
pub fn flag_modified(&mut self, id: Index)
[src]
pub fn flag_modified(&mut self, id: Index)
Flags an index as modified.
pub fn flag_inserted(&mut self, id: Index)
[src]
pub fn flag_inserted(&mut self, id: Index)
Flags an index as inserted.
pub fn flag_removed(&mut self, id: Index)
[src]
pub fn flag_removed(&mut self, id: Index)
Flags an index as removed.
impl<'e, T, D> Storage<'e, T, D>
[src]
impl<'e, T, D> Storage<'e, T, D>
pub fn new(entities: Fetch<'e, EntitiesRes>, data: D) -> Storage<'e, T, D>
[src]
pub fn new(entities: Fetch<'e, EntitiesRes>, data: D) -> Storage<'e, T, D>
Create a new Storage
impl<'e, T, D> Storage<'e, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
[src]
impl<'e, T, D> Storage<'e, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
pub fn unprotected_storage(&self) -> &T::Storage
[src]
pub fn unprotected_storage(&self) -> &T::Storage
Gets the wrapped storage.
pub fn get(&self, e: Entity) -> Option<&T>
[src]
pub fn get(&self, e: Entity) -> Option<&T>
Tries to read the data associated with an Entity
.
pub fn contains(&self, e: Entity) -> bool
[src]
pub fn contains(&self, e: Entity) -> bool
Returns true if the storage has a component for this entity, and that entity is alive.
pub fn mask(&self) -> &BitSet
[src]
pub fn mask(&self) -> &BitSet
Returns a reference to the bitset of this storage which allows filtering by the component type without actually getting the component.
impl<'e, T, D> Storage<'e, T, D> where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
[src]
impl<'e, T, D> Storage<'e, T, D> where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
pub unsafe fn unprotected_storage_mut(&mut self) -> &mut T::Storage
[src]
pub unsafe fn unprotected_storage_mut(&mut self) -> &mut T::Storage
Gets mutable access to the wrapped storage.
This is unsafe because modifying the wrapped storage without also updating the mask bitset accordingly can result in illegal memory access.
pub fn get_mut(&mut self, e: Entity) -> Option<&mut T>
[src]
pub fn get_mut(&mut self, e: Entity) -> Option<&mut T>
Tries to mutate the data associated with an Entity
.
pub fn entry<'a>(
&'a mut self,
e: Entity
) -> Result<StorageEntry<'a, 'e, T, D>, WrongGeneration> where
'e: 'a,
[src]
pub fn entry<'a>(
&'a mut self,
e: Entity
) -> Result<StorageEntry<'a, 'e, T, D>, WrongGeneration> where
'e: 'a,
Returns an entry to the component associated to the entity.
Behaves somewhat similarly to std::collections::HashMap
's entry api.
Example
if let Ok(entry) = storage.entry(entity) { entry.or_insert(Comp { field: 55 }); }
pub fn insert(&mut self, e: Entity, v: T) -> InsertResult<T>
[src]
pub fn insert(&mut self, e: Entity, v: T) -> InsertResult<T>
Inserts new data for a given Entity
.
Returns the result of the operation as a InsertResult<T>
pub fn remove(&mut self, e: Entity) -> Option<T>
[src]
pub fn remove(&mut self, e: Entity) -> Option<T>
Removes the data associated with an Entity
.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Clears the contents of the storage.
pub fn drain(&mut self) -> Drain<T>
[src]
pub fn drain(&mut self) -> Drain<T>
Creates a draining storage wrapper which can be .join
ed
to get a draining iterator.
Trait Implementations
impl<'a, T: Component, D> DistinctStorage for Storage<'a, T, D> where
T::Storage: DistinctStorage,
[src]
impl<'a, T: Component, D> DistinctStorage for Storage<'a, T, D> where
T::Storage: DistinctStorage,
impl<'a, 'e, T, D> Join for &'a Storage<'e, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
[src]
impl<'a, 'e, T, D> Join for &'a Storage<'e, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
type Type = &'a T
Type of joined components.
type Value = &'a T::Storage
Type of joined storages.
type Mask = &'a BitSet
Type of joined bit mask.
unsafe fn open(self) -> (Self::Mask, Self::Value)
[src]
unsafe fn open(self) -> (Self::Mask, Self::Value)
Open this join by returning the mask and the storages. Read more
ⓘImportant traits for &'a mut Runsafe fn get(v: &mut Self::Value, i: Index) -> &'a T
[src]
unsafe fn get(v: &mut Self::Value, i: Index) -> &'a T
Get a joined component value by a given index.
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self> where
Self: Sized,
[src]
fn join(self) -> JoinIter<Self> where
Self: Sized,
Create a joined iterator over the contents.
impl<'a, 'e, T, D> Not for &'a Storage<'e, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
[src]
impl<'a, 'e, T, D> Not for &'a Storage<'e, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
type Output = AntiStorage<'a>
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
fn not(self) -> Self::Output
Performs the unary !
operation.
impl<'a, 'e, T, D> ParJoin for &'a Storage<'e, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
T::Storage: Sync,
[src]
impl<'a, 'e, T, D> ParJoin for &'a Storage<'e, T, D> where
T: Component,
D: Deref<Target = MaskedStorage<T>>,
T::Storage: Sync,
fn par_join(self) -> JoinParIter<Self> where
Self: Sized,
[src]
fn par_join(self) -> JoinParIter<Self> where
Self: Sized,
Create a joined parallel iterator over the contents.
impl<'a, 'e, T, D> Join for &'a mut Storage<'e, T, D> where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
[src]
impl<'a, 'e, T, D> Join for &'a mut Storage<'e, T, D> where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
type Type = &'a mut T
Type of joined components.
type Value = &'a mut T::Storage
Type of joined storages.
type Mask = &'a BitSet
Type of joined bit mask.
unsafe fn open(self) -> (Self::Mask, Self::Value)
[src]
unsafe fn open(self) -> (Self::Mask, Self::Value)
Open this join by returning the mask and the storages. Read more
ⓘImportant traits for &'a mut Runsafe fn get(v: &mut Self::Value, i: Index) -> &'a mut T
[src]
unsafe fn get(v: &mut Self::Value, i: Index) -> &'a mut T
Get a joined component value by a given index.
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self> where
Self: Sized,
[src]
fn join(self) -> JoinIter<Self> where
Self: Sized,
Create a joined iterator over the contents.
impl<'a, 'e, T, D> ParJoin for &'a mut Storage<'e, T, D> where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
T::Storage: Sync + DistinctStorage,
[src]
impl<'a, 'e, T, D> ParJoin for &'a mut Storage<'e, T, D> where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
T::Storage: Sync + DistinctStorage,
fn par_join(self) -> JoinParIter<Self> where
Self: Sized,
[src]
fn par_join(self) -> JoinParIter<Self> where
Self: Sized,
Create a joined parallel iterator over the contents.