Trait UnknownComponentStorage

Source
pub trait UnknownComponentStorage:
    Downcast
    + Send
    + Sync {
Show 13 methods // Required 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 + 'static), ); fn transfer_component( &mut self, src_archetype: ArchetypeIndex, src_component: ComponentIndex, dst_archetype: ArchetypeIndex, dst: &mut (dyn UnknownComponentStorage + 'static), ); 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: u64) -> 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§

Source

fn increment_epoch(&mut self)

Notifies the storage of the start of a new epoch.

Source

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

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

Source

fn transfer_archetype( &mut self, src_archetype: ArchetypeIndex, dst_archetype: ArchetypeIndex, dst: &mut (dyn UnknownComponentStorage + 'static), )

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

Source

fn transfer_component( &mut self, src_archetype: ArchetypeIndex, src_component: ComponentIndex, dst_archetype: ArchetypeIndex, dst: &mut (dyn UnknownComponentStorage + 'static), )

Moves a component to a new storage.

Source

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

Moves a component from one archetype to another.

Source

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

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

Source

fn pack(&mut self, epoch_threshold: u64) -> usize

Packs archetype slices.

Source

fn fragmentation(&self) -> f32

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

Source

fn element_vtable(&self) -> ComponentMeta

Returns the component metadata.

Source

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

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

Source

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

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.

Source

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

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.

Source

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

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§

Source§

impl dyn UnknownComponentStorage

Source

pub fn is<__T>(&self) -> bool

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

Source

pub fn downcast<__T>( self: Box<dyn UnknownComponentStorage>, ) -> Result<Box<__T>, Box<dyn UnknownComponentStorage>>

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.

Source

pub fn downcast_rc<__T>( self: Rc<dyn UnknownComponentStorage>, ) -> Result<Rc<__T>, Rc<dyn UnknownComponentStorage>>

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.

Source

pub fn downcast_ref<__T>(&self) -> Option<&__T>

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

Source

pub fn downcast_mut<__T>(&mut self) -> Option<&mut __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§