Trait bevy_ecs::bundle::Bundle [−][src]
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
fn type_info() -> Vec<TypeInfo>
[src]
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 where
Self: Sized,
[src]
Self: Sized,
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))
[src]
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
impl Bundle for ()
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component> Bundle for (C0,)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component> Bundle for (C0, C1)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component> Bundle for (C0, C1, C2)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component> Bundle for (C0, C1, C2, C3)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component> Bundle for (C0, C1, C2, C3, C4)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component> Bundle for (C0, C1, C2, C3, C4, C5)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component, C7: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component, C7: Component, C8: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component, C7: Component, C8: Component, C9: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component, C7: Component, C8: Component, C9: Component, C10: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component, C7: Component, C8: Component, C9: Component, C10: Component, C11: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component, C7: Component, C8: Component, C9: Component, C10: Component, C11: Component, C12: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component, C7: Component, C8: Component, C9: Component, C10: Component, C11: Component, C12: Component, C13: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order
fn type_info() -> Vec<TypeInfo>
[src]
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
[src]
fn get_components(self, func: impl FnMut(*mut u8))
[src]
impl<C0: Component, C1: Component, C2: Component, C3: Component, C4: Component, C5: Component, C6: Component, C7: Component, C8: Component, C9: Component, C10: Component, C11: Component, C12: Component, C13: Component, C14: Component> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14)
[src]
SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order