Struct specs::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: DerefMut<Target = MaskedStorage<T>>, 
[src]

[src]

Builds a mutable RestrictedStorage out of a Storage. Allows restricted access to the inner components without allowing invalidating the bitset for iteration in Join.

[src]

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 + Deserialize<'e>,
    D: DerefMut<Target = MaskedStorage<T>>, 
[src]

[src]

Merges a list of components into the storage.

The list of entities will be used as the base for the offsets of the packed data.

e.g. rust,ignore let list = vec![Entity(0, 1), Entity(1, 1), Entity(2, 1)]; let packed = PackedData { offsets: [0, 2], components: [ ... ] }; storage.merge(&list, packed); Would merge the components at offset 0 and 2, which would be Entity(0, 1) and Entity(2, 1) while ignoring Entity(1, 1).

Note: The entity list should be at least the same size as the packed data. To make sure, you can call packed.pair_truncate(&entities). If the entity list is larger than the packed data then those entities are ignored.

Packed data should also be sorted in ascending order of offsets. If this is deserialized from data received from serializing a storage it will be in ascending order.

impl<'e, T, D> Storage<'e, T, D>
[src]

[src]

Create a new Storage

impl<'e, T, D> Storage<'e, T, D> where
    T: Component,
    D: Deref<Target = MaskedStorage<T>>, 
[src]

[src]

Tries to read the data associated with an Entity.

[src]

Returns a copy of the BitSet of the storage. This allows you to do some methods on the actual storage without worrying about borrowing semantics.

This bitset can be invalidated here if insertion or removal methods are used after the call to get the BitSet, so there is no guarantee that the storage will have a component for a specific entity.

impl<'e, T, D> Storage<'e, T, D> where
    T: Component,
    D: DerefMut<Target = MaskedStorage<T>>, 
[src]

[src]

Tries to mutate the data associated with an Entity.

[src]

Inserts new data for a given Entity. Returns the result of the operation as a InsertResult<T>

[src]

Removes the data associated with an Entity.

[src]

Clears the contents of the storage.

[src]

Creates a draining storage wrapper which can be .joined to get a draining iterator.

Trait Implementations

impl<'e, T, D> Serialize for Storage<'e, T, D> where
    T: Component + Serialize,
    D: Deref<Target = MaskedStorage<T>>, 
[src]

[src]

Serialize this value into the given Serde serializer. Read more

impl<'a, T: Component, D> DistinctStorage for Storage<'a, T, D> where
    T::Storage: DistinctStorage
[src]

impl<'a, 'e, T, D> Join for &'a Storage<'e, T, D> where
    T: Component,
    D: Deref<Target = MaskedStorage<T>>, 
[src]

Type of joined components.

Type of joined storages.

Type of joined bit mask.

[src]

Open this join by returning the mask and the storages.

[src]

Get a joined component value by a given index.

[src]

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]

The resulting type after applying the ! operator.

[src]

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]

[src]

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]

Type of joined components.

Type of joined storages.

Type of joined bit mask.

[src]

Open this join by returning the mask and the storages.

[src]

Get a joined component value by a given index.

[src]

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]

[src]

Create a joined parallel iterator over the contents.