Trait rfw::ecs::Bundle [−][src]
pub unsafe trait Bundle: 'static + Send + Sync { fn type_info() -> Vec<TypeInfo, Global>; unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self; fn get_components(self, func: impl FnMut(*mut u8)); }
Expand description
An ordered collection of components, commonly used for spawning entities, and adding and removing components in bulk.
You cannot query for a bundle, only individual components within it.
Typically, you will simply use #[derive(Bundle)]
when creating your own Bundle
.
The Bundle
trait is automatically implemented for tuples of components:
(ComponentA, ComponentB)
is a very convenient shorthand when working with one-off collections
of components. Note that both ()
and (ComponentA, )
are valid tuples.
You can nest bundles like so:
#[derive(Bundle)] struct A { x: i32, y: u64, } #[derive(Bundle)] struct B { #[bundle] a: A, z: String, }
Safety
Bundle::type_info must return the TypeInfo for each component type in the bundle, in the
exact order that Bundle::get_components is called.
Bundle::from_components must call func
exactly once for each TypeInfo returned by
Bundle::type_info
Required methods
Gets this Bundle’s components type info, in the order of this bundle’s Components
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
Calls func
, which should return data for each component in the bundle, in the order of
this bundle’s Components
Safety
Caller must return data for each component in the bundle, in the order of this bundle’s Components
fn get_components(self, func: impl FnMut(*mut u8))
fn get_components(self, func: impl FnMut(*mut u8))
Calls func
on each value, in the order of this bundle’s Components. This will
“mem::forget” the bundle fields, so callers are responsible for dropping the fields if
that is desirable.
Implementations on Foreign Types
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11) where
C8: Component,
C0: Component,
C1: Component,
C2: Component,
C3: Component,
C4: Component,
C5: Component,
C6: Component,
C7: Component,
C9: Component,
C10: Component,
C11: Component,
impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11) where
C8: Component,
C0: Component,
C1: Component,
C2: Component,
C3: Component,
C4: Component,
C5: Component,
C6: Component,
C7: Component,
C9: Component,
C10: Component,
C11: Component,
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12) where
C8: Component,
C0: Component,
C1: Component,
C2: Component,
C3: Component,
C4: Component,
C5: Component,
C6: Component,
C7: Component,
C9: Component,
C10: Component,
C11: Component,
C12: Component,
impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12) where
C8: Component,
C0: Component,
C1: Component,
C2: Component,
C3: Component,
C4: Component,
C5: Component,
C6: Component,
C7: Component,
C9: Component,
C10: Component,
C11: Component,
C12: Component,
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14) where
C8: Component,
C0: Component,
C1: Component,
C2: Component,
C3: Component,
C4: Component,
C5: Component,
C6: Component,
C7: Component,
C9: Component,
C10: Component,
C11: Component,
C12: Component,
C13: Component,
C14: Component,
impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14) where
C8: Component,
C0: Component,
C1: Component,
C2: Component,
C3: Component,
C4: Component,
C5: Component,
C6: Component,
C7: Component,
C9: Component,
C10: Component,
C11: Component,
C12: Component,
C13: Component,
C14: Component,
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13) where
C8: Component,
C0: Component,
C1: Component,
C2: Component,
C3: Component,
C4: Component,
C5: Component,
C6: Component,
C7: Component,
C9: Component,
C10: Component,
C11: Component,
C12: Component,
C13: Component,
impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13) where
C8: Component,
C0: Component,
C1: Component,
C2: Component,
C3: Component,
C4: Component,
C5: Component,
C6: Component,
C7: Component,
C9: Component,
C10: Component,
C11: Component,
C12: Component,
C13: Component,
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order