Trait bevy::ecs::bundle::Bundle[]

pub unsafe trait Bundle: 'static + Send + Sync {
    pub fn type_info() -> Vec<TypeInfo, Global>

Notable traits for Vec<u8, A>

impl<A> Write for Vec<u8, A> where
    A: Allocator
;
pub unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self;
pub fn get_components(self, func: impl FnMut(*mut u8)); }

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

pub fn type_info() -> Vec<TypeInfo, Global>

Notable traits for Vec<u8, A>

impl<A> Write for Vec<u8, A> where
    A: Allocator

Gets this Bundle’s components type info, in the order of this bundle’s Components

pub 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

pub 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.

Loading content...

Implementations on Foreign Types

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
    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

SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order

impl<C0, C1, C2, C3> Bundle for (C0, C1, C2, C3) where
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component

SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order

impl Bundle for ()

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
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component,
    C4: Component,
    C5: Component,
    C6: Component,
    C7: Component,
    C8: Component,
    C9: Component,
    C10: Component,
    C11: 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> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8) where
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component,
    C4: Component,
    C5: Component,
    C6: Component,
    C7: Component,
    C8: Component

SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order

impl<C0, C1, C2> Bundle for (C0, C1, C2) where
    C0: Component,
    C1: Component,
    C2: Component

SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order

impl<C0, C1> Bundle for (C0, C1) where
    C0: Component,
    C1: 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> Bundle for (C0, C1, C2, C3, C4, C5) where
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component,
    C4: Component,
    C5: 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
    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

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> Bundle for (C0, C1, C2, C3, C4, C5, C6) where
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component,
    C4: Component,
    C5: Component,
    C6: 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> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) where
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component,
    C4: Component,
    C5: Component,
    C6: Component,
    C7: Component,
    C8: Component,
    C9: 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> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7) where
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component,
    C4: Component,
    C5: Component,
    C6: Component,
    C7: 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> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10) where
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component,
    C4: Component,
    C5: Component,
    C6: Component,
    C7: Component,
    C8: Component,
    C9: Component,
    C10: Component

SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order

impl<C0> Bundle for (C0,) where
    C0: Component

SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order

impl<C0, C1, C2, C3, C4> Bundle for (C0, C1, C2, C3, C4) where
    C0: Component,
    C1: Component,
    C2: Component,
    C3: Component,
    C4: 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> Bundle for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13) where
    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

SAFE: TypeInfo is returned in tuple-order. Bundle::from_components and Bundle::get_components use tuple-order

Loading content...

Implementors

impl Bundle for LightBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for PbrBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for MeshBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for OrthographicCameraBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for PerspectiveCameraBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for SpriteBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for SpriteSheetBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for Text2dBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for ButtonBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for ImageBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for NodeBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for TextBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

impl Bundle for UiCameraBundle

SAFE: TypeInfo is returned in field-definition-order. [from_components] and [get_components] use field-definition-order

Loading content...