Trait legion::storage::UnknownComponentStorage[][src]

pub trait UnknownComponentStorage: Downcast + Send + Sync {
Show 13 methods fn increment_epoch(&mut self);
fn insert_archetype(
        &mut self,
        archetype: ArchetypeIndex,
        index: Option<usize>
    );
fn transfer_archetype(
        &mut self,
        src_archetype: ArchetypeIndex,
        dst_archetype: ArchetypeIndex,
        dst: &mut dyn UnknownComponentStorage
    );
fn transfer_component(
        &mut self,
        src_archetype: ArchetypeIndex,
        src_component: ComponentIndex,
        dst_archetype: ArchetypeIndex,
        dst: &mut dyn UnknownComponentStorage
    );
fn move_component(
        &mut self,
        source: ArchetypeIndex,
        index: ComponentIndex,
        dst: ArchetypeIndex
    );
fn swap_remove(&mut self, archetype: ArchetypeIndex, index: ComponentIndex);
fn pack(&mut self, epoch_threshold: Epoch) -> usize;
fn fragmentation(&self) -> f32;
fn element_vtable(&self) -> ComponentMeta;
fn get_raw(&self, archetype: ArchetypeIndex) -> Option<(*const u8, usize)>;
unsafe fn get_mut_raw(
        &self,
        archetype: ArchetypeIndex
    ) -> Option<(*mut u8, usize)>;
unsafe fn extend_memcopy_raw(
        &mut self,
        archetype: ArchetypeIndex,
        ptr: *const u8,
        len: usize
    );
fn ensure_capacity(&mut self, archetype: ArchetypeIndex, space: usize);
}
Expand description

A storage location for component data slices. Each component storage may hold one slice for each archetype inserted into the storage. The type of component stored is not known statically.

Required methods

Notifies the storage of the start of a new epoch.

Inserts a new empty component slice for an archetype into this storage.

Moves an archetype’s component slice to a new storage.

Moves a component to a new storage.

Moves a component from one archetype to another.

Removes a component from an archetype slice, swapping it with the last component in the slice.

Packs archetype slices.

A heuristic estimating cache misses for an iteration through all components due to archetype fragmentation.

Returns the component metadata.

Returns a pointer to the given archetype’s component slice.

Returns a pointer to the given archetype’s component slice.

Safety

The caller is responsible for ensuring that they have exclusive access to the given archetype’s slice.

Writes new components into the given archetype’s component slice via a memcopy.

Safety

ptr must point to a valid array of the correct component type of length at least as long as len. The data in this array will be memcopied into the world’s internal storage. If the component type is not Copy, then the caller must ensure that the memory copied is not accessed until it is re-initialized. It is recommended to immediately std::mem::forget the source after calling extend_memcopy_raw.

Ensures that the given spare capacity is available for component insertions. This is a performance hint and should not be required before extend_memcopy is called.

Implementations

Returns true if the trait object wraps an object of type __T.

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Implementors