pub trait UnprotectedStorage<T>: TryDefault {
    type AccessMut<'a>: AccessMut<Target = T>
       where Self: 'a;

    // Required methods
    unsafe fn clean<B>(&mut self, has: B)
       where B: BitSetLike;
    unsafe fn get(&self, id: Index) -> &T;
    unsafe fn get_mut(&mut self, id: Index) -> Self::AccessMut<'_>;
    unsafe fn insert(&mut self, id: Index, value: T);
    unsafe fn remove(&mut self, id: Index) -> T;

    // Provided method
    unsafe fn drop(&mut self, id: Index) { ... }
}
Expand description

Used by the framework to quickly join components.

Required Associated Types§

source

type AccessMut<'a>: AccessMut<Target = T> where Self: 'a

The wrapper through with mutable access of a component is performed.

Required Methods§

source

unsafe fn clean<B>(&mut self, has: B)where B: BitSetLike,

Clean the storage given a bitset with bits set for valid indices dropping all existing components.

Allows us to drop the storage without leaking components.

Safety

May only be called with the mask which keeps track of the elements existing in this storage.

If this unwinds (e.g. due to a drop impl panicing), the mask should still be cleared.

source

unsafe fn get(&self, id: Index) -> &T

Gets a shared reference to the data associated with an Index.

This is unsafe because the external set used to protect this storage is absent.

Safety

May only be called after a call to insert with id and no following call to remove with id or to clean.

A mask should keep track of those states, and an id being contained in the tracking mask is sufficient to call this method.

source

unsafe fn get_mut(&mut self, id: Index) -> Self::AccessMut<'_>

Gets mutable access to the the data associated with an Index.

This doesn’t necessarily directly return a &mut reference. This allows storages more flexibility. For example, some flagged storages utilize this to defer generation of mutation events until the user obtains an &mut reference out of the returned wrapper type.

This is unsafe because the external set used to protect this storage is absent.

Safety

May only be called after a call to insert with id and no following call to remove with id or to clean.

A mask should keep track of those states, and an id being contained in the tracking mask is sufficient to call this method.

source

unsafe fn insert(&mut self, id: Index, value: T)

Inserts new data for a given Index.

Safety

May only be called if insert was not called with id before, or was reverted by a call to remove with id or a call to clean.

A mask should keep track of those states, and an id missing from the mask is sufficient to call insert.

If this call unwinds the insertion should be considered to have failed and not be included in the mask or count as having called insert for the safety requirements of other methods here.

source

unsafe fn remove(&mut self, id: Index) -> T

Removes the data associated with an Index.

Safety

May only be called if an element with id was inserted and not yet removed / dropped.

Provided Methods§

source

unsafe fn drop(&mut self, id: Index)

Drops the data associated with an Index. This could be used when a more efficient implementation for it exists than remove when the data is no longer needed. Defaults to simply calling remove.

Safety

May only be called if an element with id was inserted and not yet removed / dropped.

Caller must ensure this is cleared from the mask even if the drop impl of the component panics and this unwinds. Usually, this can be accomplished by removing the id from the mask just before calling this.

Implementors§

source§

impl<C: Component, T: UnprotectedStorage<C>> UnprotectedStorage<C> for DerefFlaggedStorage<C, T>

§

type AccessMut<'a> = FlaggedAccessMut<'a, <T as UnprotectedStorage<C>>::AccessMut<'a>, C> where T: 'a

source§

impl<C: Component, T: UnprotectedStorage<C>> UnprotectedStorage<C> for FlaggedStorage<C, T>

§

type AccessMut<'a> = <T as UnprotectedStorage<C>>::AccessMut<'a> where T: 'a

source§

impl<T> UnprotectedStorage<T> for BTreeStorage<T>

§

type AccessMut<'a> = &'a mut T where T: 'a

source§

impl<T> UnprotectedStorage<T> for DefaultVecStorage<T>where T: Default,

§

type AccessMut<'a> = &'a mut T where T: 'a

source§

impl<T> UnprotectedStorage<T> for DenseVecStorage<T>

§

type AccessMut<'a> = &'a mut T where T: 'a

source§

impl<T> UnprotectedStorage<T> for HashMapStorage<T>

§

type AccessMut<'a> = &'a mut T where T: 'a

source§

impl<T> UnprotectedStorage<T> for NullStorage<T>

§

type AccessMut<'a> = &'a mut T where T: 'a

source§

impl<T> UnprotectedStorage<T> for VecStorage<T>

§

type AccessMut<'a> = &'a mut T where T: 'a