Struct bones_framework::lib::prelude::ComponentStore
source · pub struct ComponentStore<T>where
T: HasSchema,{ /* private fields */ }
Expand description
A typed wrapper around UntypedComponentStore
.
Implementations§
source§impl<T> ComponentStore<T>where
T: HasSchema,
impl<T> ComponentStore<T>where
T: HasSchema,
sourcepub fn into_untyped(self) -> UntypedComponentStore
pub fn into_untyped(self) -> UntypedComponentStore
Converts to the internal, untyped ComponentStore
.
sourcepub fn from_untyped(untyped: UntypedComponentStore) -> ComponentStore<T>
pub fn from_untyped(untyped: UntypedComponentStore) -> ComponentStore<T>
Creates a ComponentStore
from an UntypedComponentStore
.
§Panics
Panics if the schema doesn’t match T
.
sourcepub fn insert(&mut self, entity: Entity, component: T) -> Option<T>
pub fn insert(&mut self, entity: Entity, component: T) -> Option<T>
Inserts a component for the given Entity
index.
Returns the previous component, if any.
sourcepub fn get(&self, entity: Entity) -> Option<&T>
pub fn get(&self, entity: Entity) -> Option<&T>
Gets an immutable reference to the component of Entity
.
sourcepub fn get_mut(&mut self, entity: Entity) -> Option<&mut T>
pub fn get_mut(&mut self, entity: Entity) -> Option<&mut T>
Gets a mutable reference to the component of Entity
.
sourcepub fn get_mut_or_insert(
&mut self,
entity: Entity,
f: impl FnOnce() -> T,
) -> &mut T
pub fn get_mut_or_insert( &mut self, entity: Entity, f: impl FnOnce() -> T, ) -> &mut T
Get a mutable reference to component if it exists.
Otherwise inserts T
generated by calling parameter: f
.
sourcepub fn get_many_mut<const N: usize>(
&mut self,
entities: [Entity; N],
) -> [Option<&mut T>; N]
pub fn get_many_mut<const N: usize>( &mut self, entities: [Entity; N], ) -> [Option<&mut T>; N]
Get mutable references to the component data for multiple entities at the same time.
§Panics
This will panic if the same entity is specified multiple times. This is invalid because it would mean you would have two mutable references to the same component data at the same time.
sourcepub fn remove(&mut self, entity: Entity) -> Option<T>
pub fn remove(&mut self, entity: Entity) -> Option<T>
Removes the component of Entity
.
Returns Some(T)
if the entity did have the component.
Returns None
if the entity did not have the component.
sourcepub fn get_single_with_bitset(
&self,
bitset: Rc<BitSetVec>,
) -> Result<&T, QuerySingleError>
pub fn get_single_with_bitset( &self, bitset: Rc<BitSetVec>, ) -> Result<&T, QuerySingleError>
Gets an immutable reference to the component if there is exactly one instance of it.
sourcepub fn get_single_with_bitset_mut(
&mut self,
bitset: Rc<BitSetVec>,
) -> Result<&mut T, QuerySingleError>
pub fn get_single_with_bitset_mut( &mut self, bitset: Rc<BitSetVec>, ) -> Result<&mut T, QuerySingleError>
Gets a mutable reference to the component if there is exactly one instance of it.
Trait Implementations§
source§impl<T> Clone for ComponentStore<T>
impl<T> Clone for ComponentStore<T>
source§fn clone(&self) -> ComponentStore<T>
fn clone(&self) -> ComponentStore<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a, T> ComponentIterBitset<'a, T> for ComponentStore<T>where
T: HasSchema,
impl<'a, T> ComponentIterBitset<'a, T> for ComponentStore<T>where
T: HasSchema,
source§fn get_single_with_bitset(
&self,
bitset: Rc<BitSetVec>,
) -> Result<&T, QuerySingleError>
fn get_single_with_bitset( &self, bitset: Rc<BitSetVec>, ) -> Result<&T, QuerySingleError>
Gets an immutable reference to the component if there is exactly one instance of it.
source§fn get_single_mut_with_bitset(
&mut self,
bitset: Rc<BitSetVec>,
) -> Result<&mut T, QuerySingleError>
fn get_single_mut_with_bitset( &mut self, bitset: Rc<BitSetVec>, ) -> Result<&mut T, QuerySingleError>
Gets a mutable reference to the component if there is exactly one instance of it.
source§fn iter_with_bitset(
&self,
bitset: Rc<BitSetVec>,
) -> Map<UntypedComponentBitsetIterator<'_>, for<'b> fn(_: SchemaRef<'b>) -> &'b T> ⓘ
fn iter_with_bitset( &self, bitset: Rc<BitSetVec>, ) -> Map<UntypedComponentBitsetIterator<'_>, for<'b> fn(_: SchemaRef<'b>) -> &'b T> ⓘ
Iterates immutably over the components of this type where bitset
indicates the indices of entities.
Slower than iter()
but allows joining between multiple component types.
source§fn iter_with_bitset_optional(
&self,
bitset: Rc<BitSetVec>,
) -> Map<UntypedComponentOptionalBitsetIterator<'_>, for<'b> fn(_: Option<SchemaRef<'b>>) -> Option<&'b T>> ⓘ
fn iter_with_bitset_optional( &self, bitset: Rc<BitSetVec>, ) -> Map<UntypedComponentOptionalBitsetIterator<'_>, for<'b> fn(_: Option<SchemaRef<'b>>) -> Option<&'b T>> ⓘ
Iterates immutably over the components of this type where bitset
indicates the indices of entities where iterator returns an Option.
None is returned for entities in bitset when Component is not in ComponentStore
source§fn iter_mut_with_bitset(
&mut self,
bitset: Rc<BitSetVec>,
) -> Map<UntypedComponentBitsetIteratorMut<'_>, for<'b> fn(_: SchemaRefMut<'b>) -> &'b mut T> ⓘ
fn iter_mut_with_bitset( &mut self, bitset: Rc<BitSetVec>, ) -> Map<UntypedComponentBitsetIteratorMut<'_>, for<'b> fn(_: SchemaRefMut<'b>) -> &'b mut T> ⓘ
Iterates mutable over the components of this type where bitset
indicates the indices of entities.
Slower than iter()
but allows joining between multiple component types.
source§fn iter_mut_with_bitset_optional(
&mut self,
bitset: Rc<BitSetVec>,
) -> Map<UntypedComponentOptionalBitsetIteratorMut<'_>, for<'b> fn(_: Option<SchemaRefMut<'b>>) -> Option<&'b mut T>> ⓘ
fn iter_mut_with_bitset_optional( &mut self, bitset: Rc<BitSetVec>, ) -> Map<UntypedComponentOptionalBitsetIteratorMut<'_>, for<'b> fn(_: Option<SchemaRefMut<'b>>) -> Option<&'b mut T>> ⓘ
Iterates mutably over the components of this type where bitset
indicates the indices of entities where iterator returns an Option.
None is returned for entities in bitset when Component is not in [ComponentStore
source§fn bitset(&self) -> &BitSetVec
fn bitset(&self) -> &BitSetVec
Read the bitset containing the list of entites with this component type on it.
source§fn contains(&self, entity: Entity) -> bool
fn contains(&self, entity: Entity) -> bool
Check whether or not this component store has data for the given entity.
source§fn component_store(&self) -> &ComponentStore<T>
fn component_store(&self) -> &ComponentStore<T>
ComponentStore
for usage with generic types implementing ComponentIterBitset
.source§impl<T> Default for ComponentStore<T>where
T: HasSchema,
impl<T> Default for ComponentStore<T>where
T: HasSchema,
source§fn default() -> ComponentStore<T>
fn default() -> ComponentStore<T>
source§impl<T> TryFrom<UntypedComponentStore> for ComponentStore<T>where
T: HasSchema,
impl<T> TryFrom<UntypedComponentStore> for ComponentStore<T>where
T: HasSchema,
§type Error = SchemaMismatchError
type Error = SchemaMismatchError
source§fn try_from(
untyped: UntypedComponentStore,
) -> Result<ComponentStore<T>, <ComponentStore<T> as TryFrom<UntypedComponentStore>>::Error>
fn try_from( untyped: UntypedComponentStore, ) -> Result<ComponentStore<T>, <ComponentStore<T> as TryFrom<UntypedComponentStore>>::Error>
Auto Trait Implementations§
impl<T> Freeze for ComponentStore<T>
impl<T> !RefUnwindSafe for ComponentStore<T>
impl<T> Send for ComponentStore<T>
impl<T> Sync for ComponentStore<T>
impl<T> Unpin for ComponentStore<T>where
T: Unpin,
impl<T> !UnwindSafe for ComponentStore<T>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Self
using data from the given World
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> RawDefault for Twhere
T: Default,
impl<T> RawDefault for Twhere
T: Default,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.