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

pub trait UnknownComponentStorage: Downcast + Send + Sync {
    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); }

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

fn increment_epoch(&mut self)[src]

Notifies the storage of the start of a new epoch.

fn insert_archetype(&mut self, archetype: ArchetypeIndex, index: Option<usize>)[src]

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

fn transfer_archetype(
    &mut self,
    src_archetype: ArchetypeIndex,
    dst_archetype: ArchetypeIndex,
    dst: &mut dyn UnknownComponentStorage
)
[src]

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

fn transfer_component(
    &mut self,
    src_archetype: ArchetypeIndex,
    src_component: ComponentIndex,
    dst_archetype: ArchetypeIndex,
    dst: &mut dyn UnknownComponentStorage
)
[src]

Moves a component to a new storage.

fn move_component(
    &mut self,
    source: ArchetypeIndex,
    index: ComponentIndex,
    dst: ArchetypeIndex
)
[src]

Moves a component from one archetype to another.

fn swap_remove(&mut self, archetype: ArchetypeIndex, index: ComponentIndex)[src]

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

fn pack(&mut self, epoch_threshold: Epoch) -> usize[src]

Packs archetype slices.

fn fragmentation(&self) -> f32[src]

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

fn element_vtable(&self) -> ComponentMeta[src]

Returns the component metadata.

fn get_raw(&self, archetype: ArchetypeIndex) -> Option<(*const u8, usize)>[src]

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

unsafe fn get_mut_raw(
    &self,
    archetype: ArchetypeIndex
) -> Option<(*mut u8, usize)>
[src]

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.

unsafe fn extend_memcopy_raw(
    &mut self,
    archetype: ArchetypeIndex,
    ptr: *const u8,
    len: usize
)
[src]

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.

fn ensure_capacity(&mut self, archetype: ArchetypeIndex, space: usize)[src]

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.

Loading content...

Implementations

impl dyn UnknownComponentStorage[src]

pub fn is<__T: UnknownComponentStorage>(&self) -> bool[src]

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

pub fn downcast<__T: UnknownComponentStorage>(
    self: Box<Self>
) -> Result<Box<__T>, Box<Self>>
[src]

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.

pub fn downcast_rc<__T: UnknownComponentStorage>(
    self: Rc<Self>
) -> Result<Rc<__T>, Rc<Self>>
[src]

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.

pub fn downcast_ref<__T: UnknownComponentStorage>(&self) -> Option<&__T>[src]

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

pub fn downcast_mut<__T: UnknownComponentStorage>(&mut self) -> Option<&mut __T>[src]

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

Implementors

impl<T: Component> UnknownComponentStorage for PackedStorage<T>[src]

fn transfer_component(
    &mut self,
    src_archetype: ArchetypeIndex,
    src_component: ComponentIndex,
    dst_archetype: ArchetypeIndex,
    dst: &mut dyn UnknownComponentStorage
)
[src]

Moves a component to a new storage.

Loading content...