Struct legion::storage::PackedStorage
source · [−]pub struct PackedStorage<T: Component> { /* private fields */ }
Expand description
Stores a slice of components of type T
for each archetype.
Archetype slices are sorted according to the group that component T
belongs to.
Each slice may be packed into a single allocation to optimise for group-based access.
Trait Implementations
sourceimpl<'a, T: Component> ComponentStorage<'a, T> for PackedStorage<T>
impl<'a, T: Component> ComponentStorage<'a, T> for PackedStorage<T>
type Iter = ComponentIter<'a, T>
type Iter = ComponentIter<'a, T>
An iterator of shared archetype slice references.
type IterMut = ComponentIterMut<'a, T>
type IterMut = ComponentIterMut<'a, T>
An iterator of mutable archetype slice references.
sourceunsafe fn extend_memcopy(
&mut self,
archetype: ArchetypeIndex,
ptr: *const T,
count: usize
)
unsafe fn extend_memcopy(
&mut self,
archetype: ArchetypeIndex,
ptr: *const T,
count: usize
)
Copies new components into the specified archetype slice. Read more
sourcefn get(
&'a self,
ArchetypeIndex: ArchetypeIndex
) -> Option<ComponentSlice<'a, T>>
fn get(
&'a self,
ArchetypeIndex: ArchetypeIndex
) -> Option<ComponentSlice<'a, T>>
Gets the component slice for the specified archetype.
sourceunsafe fn get_mut(
&'a self,
ArchetypeIndex: ArchetypeIndex
) -> Option<ComponentSliceMut<'a, T>>
unsafe fn get_mut(
&'a self,
ArchetypeIndex: ArchetypeIndex
) -> Option<ComponentSliceMut<'a, T>>
Gets a mutable component slice for the specified archetype. Read more
sourcefn iter(&'a self, start_inclusive: usize, end_exclusive: usize) -> Self::Iter
fn iter(&'a self, start_inclusive: usize, end_exclusive: usize) -> Self::Iter
Iterates through all archetype component slices.
sourceimpl<T: Debug + Component> Debug for PackedStorage<T>
impl<T: Debug + Component> Debug for PackedStorage<T>
sourceimpl<T: Component> Default for PackedStorage<T>
impl<T: Component> Default for PackedStorage<T>
sourceimpl<T: Component> UnknownComponentStorage for PackedStorage<T>
impl<T: Component> UnknownComponentStorage for PackedStorage<T>
sourcefn transfer_component(
&mut self,
src_archetype: ArchetypeIndex,
src_component: ComponentIndex,
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
)
Moves a component to a new storage.
sourcefn move_component(
&mut self,
source: ArchetypeIndex,
index: ComponentIndex,
dst: ArchetypeIndex
)
fn move_component(
&mut self,
source: ArchetypeIndex,
index: ComponentIndex,
dst: ArchetypeIndex
)
Moves a component from one archetype to another.
sourcefn insert_archetype(&mut self, archetype: ArchetypeIndex, index: Option<usize>)
fn insert_archetype(&mut self, archetype: ArchetypeIndex, index: Option<usize>)
Inserts a new empty component slice for an archetype into this storage.
sourcefn transfer_archetype(
&mut self,
src_archetype: ArchetypeIndex,
dst_archetype: ArchetypeIndex,
dst: &mut dyn UnknownComponentStorage
)
fn transfer_archetype(
&mut self,
src_archetype: ArchetypeIndex,
dst_archetype: ArchetypeIndex,
dst: &mut dyn UnknownComponentStorage
)
Moves an archetype’s component slice to a new storage.
sourcefn swap_remove(&mut self, archetype: ArchetypeIndex, index: ComponentIndex)
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.
sourcefn fragmentation(&self) -> f32
fn fragmentation(&self) -> f32
A heuristic estimating cache misses for an iteration through all components due to archetype fragmentation.
sourcefn element_vtable(&self) -> ComponentMeta
fn element_vtable(&self) -> ComponentMeta
Returns the component metadata.
sourcefn get_raw(&self, ArchetypeIndex: ArchetypeIndex) -> Option<(*const u8, usize)>
fn get_raw(&self, ArchetypeIndex: ArchetypeIndex) -> Option<(*const u8, usize)>
Returns a pointer to the given archetype’s component slice.
sourceunsafe fn get_mut_raw(
&self,
ArchetypeIndex: ArchetypeIndex
) -> Option<(*mut u8, usize)>
unsafe fn get_mut_raw(
&self,
ArchetypeIndex: ArchetypeIndex
) -> Option<(*mut u8, usize)>
Returns a pointer to the given archetype’s component slice. Read more
sourceunsafe fn extend_memcopy_raw(
&mut self,
ArchetypeIndex: ArchetypeIndex,
ptr: *const u8,
count: usize
)
unsafe fn extend_memcopy_raw(
&mut self,
ArchetypeIndex: ArchetypeIndex,
ptr: *const u8,
count: usize
)
Writes new components into the given archetype’s component slice via a memcopy. Read more
sourcefn increment_epoch(&mut self)
fn increment_epoch(&mut self)
Notifies the storage of the start of a new epoch.
sourcefn ensure_capacity(&mut self, ArchetypeIndex: ArchetypeIndex, capacity: usize)
fn ensure_capacity(&mut self, ArchetypeIndex: ArchetypeIndex, capacity: 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. Read more
impl<T: Component> Send for PackedStorage<T>
impl<T: Component> Sync for PackedStorage<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for PackedStorage<T>
impl<T> Unpin for PackedStorage<T>
impl<T> UnwindSafe for PackedStorage<T> where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcepub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcepub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcepub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcepub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more