pub struct StorageWrapper<'a, T, D> { /* private fields */ }
Expand description
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.
Implementations§
Source§impl<'a, T, D> StorageWrapper<'a, T, D>
impl<'a, T, D> StorageWrapper<'a, T, D>
Source§impl<'a, T, D> StorageWrapper<'a, T, D>
impl<'a, T, D> StorageWrapper<'a, T, D>
Sourcepub fn fetched_entities(&self) -> &Entities
pub fn fetched_entities(&self) -> &Entities
Returns the Entities
resource fetched by this storage.
This does not have anything to do with the components inside.
You only want to use this when implementing additional methods
for Storage
via an extension trait.
Sourcepub fn count(&self) -> usize
pub fn count(&self) -> usize
Computes the number of elements this Storage
contains by counting the
bits in the bit set. This operation will never be performed in
constant time.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks whether this Storage
is empty. This operation is very cheap.
Sourcepub fn contains(&self, e: Entity) -> bool
pub fn contains(&self, e: Entity) -> bool
Returns true if the storage has a component for this entity, and that entity is alive.
Sourcepub fn mask(&self) -> &BitSet
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.
pub fn not(&self) -> AntiStorage<'_>
Source§impl<'a, T, D> StorageWrapper<'a, T, D>
impl<'a, T, D> StorageWrapper<'a, T, D>
Sourcepub fn get_mut(&mut self, e: Entity) -> Option<&mut T>
pub fn get_mut(&mut self, e: Entity) -> Option<&mut T>
Tries to mutate the data associated with an Entity
.
Sourcepub fn insert(
&mut self,
entity: Entity,
component: T,
) -> Result<Option<T>, Error>
pub fn insert( &mut self, entity: Entity, component: T, ) -> Result<Option<T>, Error>
Inserts new data for a given Entity
.
Returns the result of the operation as a InsertResult<T>
If a component already existed for the given Entity
, then it will
be overwritten with the new component. If it did overwrite, then the
result will contain Some(T)
where T
is the previous component.
Trait Implementations§
Source§impl<'a, 'e, T, D> Join for &'a StorageWrapper<'e, T, D>
impl<'a, 'e, T, D> Join for &'a StorageWrapper<'e, T, D>
Source§unsafe fn open(self) -> (Self::Mask, Self::Value)
unsafe fn open(self) -> (Self::Mask, Self::Value)
Source§unsafe fn get(v: &mut Self::Value, i: Index) -> &'a T
unsafe fn get(v: &mut Self::Value, i: Index) -> &'a T
Source§fn join(self) -> JoinIter<Self> ⓘwhere
Self: Sized,
fn join(self) -> JoinIter<Self> ⓘwhere
Self: Sized,
Source§fn maybe(self) -> MaybeJoin<Self>where
Self: Sized,
fn maybe(self) -> MaybeJoin<Self>where
Self: Sized,
Join
-able structure that yields all indices, returning
None
for all missing elements and Some(T)
for found elements. Read moreSource§fn is_unconstrained() -> bool
fn is_unconstrained() -> bool
Join
typically returns all indices in the mask, then iterating
over only it or combined with other joins that are also dangerous
will cause the JoinIter
/ParJoin
to go through all indices which
is usually not what is wanted and will kill performance.Source§impl<'a, 'e, T, D> Join for &'a mut StorageWrapper<'e, T, D>
impl<'a, 'e, T, D> Join for &'a mut StorageWrapper<'e, T, D>
Source§unsafe fn open(self) -> (Self::Mask, Self::Value)
unsafe fn open(self) -> (Self::Mask, Self::Value)
Source§unsafe fn get(v: &mut Self::Value, i: Index) -> &'a mut T
unsafe fn get(v: &mut Self::Value, i: Index) -> &'a mut T
Source§fn join(self) -> JoinIter<Self> ⓘwhere
Self: Sized,
fn join(self) -> JoinIter<Self> ⓘwhere
Self: Sized,
Source§fn maybe(self) -> MaybeJoin<Self>where
Self: Sized,
fn maybe(self) -> MaybeJoin<Self>where
Self: Sized,
Join
-able structure that yields all indices, returning
None
for all missing elements and Some(T)
for found elements. Read moreSource§fn is_unconstrained() -> bool
fn is_unconstrained() -> bool
Join
typically returns all indices in the mask, then iterating
over only it or combined with other joins that are also dangerous
will cause the JoinIter
/ParJoin
to go through all indices which
is usually not what is wanted and will kill performance.Source§impl<'a, 'e, T, D> Not for &'a StorageWrapper<'e, T, D>
impl<'a, 'e, T, D> Not for &'a StorageWrapper<'e, T, D>
Source§impl<'a, 'e, T, D> ParJoin for &'a StorageWrapper<'e, T, D>
impl<'a, 'e, T, D> ParJoin for &'a StorageWrapper<'e, T, D>
fn par_join(self) -> JoinParIter<Self>where
Self: Sized,
Source§impl<'a, 'e, T, D> ParJoin for &'a mut StorageWrapper<'e, T, D>
impl<'a, 'e, T, D> ParJoin for &'a mut StorageWrapper<'e, T, D>
fn par_join(self) -> JoinParIter<Self>where
Self: Sized,
impl<'a, T: Component, D> DistinctStorage for StorageWrapper<'a, T, D>where
T::Storage: DistinctStorage,
Auto Trait Implementations§
impl<'a, T, D> Freeze for StorageWrapper<'a, T, D>where
D: Freeze,
impl<'a, T, D> !RefUnwindSafe for StorageWrapper<'a, T, D>
impl<'a, T, D> Send for StorageWrapper<'a, T, D>
impl<'a, T, D> Sync for StorageWrapper<'a, T, D>
impl<'a, T, D> Unpin for StorageWrapper<'a, T, D>
impl<'a, T, D> !UnwindSafe for StorageWrapper<'a, T, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'a, T> DynamicSystemData<'a> for Twhere
T: SystemData<'a>,
impl<'a, T> DynamicSystemData<'a> for Twhere
T: SystemData<'a>,
Source§type Accessor = StaticAccessor<T>
type Accessor = StaticAccessor<T>
SystemData
, which specifies the read and write
dependencies and does the fetching.Source§fn setup(_: &StaticAccessor<T>, world: &mut World)
fn setup(_: &StaticAccessor<T>, world: &mut World)
World
for fetching this system data.