pub trait ComponentStorage<'a, T>: UnknownComponentStorage + Defaultwhere
T: Component,{
type Iter: Iterator<Item = ComponentSlice<'a, T>>;
type IterMut: Iterator<Item = ComponentSliceMut<'a, T>>;
// Required methods
fn len(&self) -> usize;
unsafe fn extend_memcopy(
&mut self,
archetype: ArchetypeIndex,
ptr: *const T,
len: usize,
);
fn get(&'a self, archetype: ArchetypeIndex) -> Option<ComponentSlice<'a, T>>;
unsafe fn get_mut(
&'a self,
archetype: ArchetypeIndex,
) -> Option<ComponentSliceMut<'a, T>>;
fn iter(
&'a self,
start_inclusive: usize,
end_exclusive: usize,
) -> Self::Iter;
unsafe fn iter_mut(
&'a self,
start_inclusive: usize,
end_exclusive: usize,
) -> Self::IterMut;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
A storage location for component data slices. Each component storage may hold once slice for each archetype inserted into the storage.
Required Associated Types§
Sourcetype Iter: Iterator<Item = ComponentSlice<'a, T>>
type Iter: Iterator<Item = ComponentSlice<'a, T>>
An iterator of shared archetype slice references.
Sourcetype IterMut: Iterator<Item = ComponentSliceMut<'a, T>>
type IterMut: Iterator<Item = ComponentSliceMut<'a, T>>
An iterator of mutable archetype slice references.
Required Methods§
Sourceunsafe fn extend_memcopy(
&mut self,
archetype: ArchetypeIndex,
ptr: *const T,
len: usize,
)
unsafe fn extend_memcopy( &mut self, archetype: ArchetypeIndex, ptr: *const T, len: usize, )
Copies new components into the specified archetype slice.
§Safety
The components located at ptr are memcopied into the storage. If T is not Copy, then the
previous memory location should no longer be accessed.
Sourcefn get(&'a self, archetype: ArchetypeIndex) -> Option<ComponentSlice<'a, T>>
fn get(&'a self, archetype: ArchetypeIndex) -> Option<ComponentSlice<'a, T>>
Gets the component slice for the specified archetype.
Sourceunsafe fn get_mut(
&'a self,
archetype: ArchetypeIndex,
) -> Option<ComponentSliceMut<'a, T>>
unsafe fn get_mut( &'a self, archetype: ArchetypeIndex, ) -> Option<ComponentSliceMut<'a, T>>
Gets a mutable component slice for the specified archetype.
§Safety
Ensure that the requested archetype slice is not concurrently borrowed anywhere else such that memory is not mutably aliased.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.