pub struct Chunk { /* private fields */ }
Expand description
A single Chunk
of entities of the same Archetype
.
The components are stored as a struct of arrays in one contiguous block of memory.
Implementations§
Source§impl Chunk
impl Chunk
Sourcepub unsafe fn from_raw(
archetype: Arc<Archetype>,
ptr: NonNull<u8>,
len: usize,
) -> Chunk
pub unsafe fn from_raw( archetype: Arc<Archetype>, ptr: NonNull<u8>, len: usize, ) -> Chunk
Create a new chunk from the raw parts.
Sourcepub fn components<T: Component>(&self) -> Option<&[T]>
pub fn components<T: Component>(&self) -> Option<&[T]>
Get a slice of components from this chunk.
Sourcepub fn components_mut<T: Component>(&mut self) -> Option<&mut [T]>
pub fn components_mut<T: Component>(&mut self) -> Option<&mut [T]>
Get a mutable list of components from this chunk.
Sourcepub fn split_by_component_mut(&mut self) -> ChunkSplitter<'_>
pub fn split_by_component_mut(&mut self) -> ChunkSplitter<'_>
Create a new ChunkSplitter
for accessing multiple component lists at the
same time.
Sourcepub fn update_at<'a>(
&mut self,
index: usize,
component_data: &impl ComponentData<'a>,
)
pub fn update_at<'a>( &mut self, index: usize, component_data: &impl ComponentData<'a>, )
Update the components of an entity in this chunk at the given index.
Sourcepub fn replace_at<'a>(
&mut self,
index: usize,
component_data: &impl ComponentData<'a>,
)
pub fn replace_at<'a>( &mut self, index: usize, component_data: &impl ComponentData<'a>, )
Replace the entity at the given index.
Sourcepub fn insert<'a>(
&mut self,
index: usize,
component_data: &impl ComponentData<'a>,
)
pub fn insert<'a>( &mut self, index: usize, component_data: &impl ComponentData<'a>, )
Insert an entity into this chunk, using the factory function provided to fill components.
Sourcepub fn copy_from(
&mut self,
insert_at: usize,
other: &Chunk,
range: impl RangeBounds<usize>,
)
pub fn copy_from( &mut self, insert_at: usize, other: &Chunk, range: impl RangeBounds<usize>, )
Insert a number of entities from another chunk at the given index.
Sourcepub fn remove(&mut self, range: impl RangeBounds<usize>)
pub fn remove(&mut self, range: impl RangeBounds<usize>)
Remove an entity from this chunk by its index into the chunk.
Sourcepub fn entity_by_index(self: &Arc<Chunk>, index: usize) -> Option<EntityEntry>
pub fn entity_by_index(self: &Arc<Chunk>, index: usize) -> Option<EntityEntry>
Get an entity entry by index.
Trait Implementations§
impl Send for Chunk
impl Sync for Chunk
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more