pub trait Bundle: Bundle { }Expand description
Tuple of zero to eight owned component values accepted by spawn and insert. Implementations are sealed so validation and insertion cannot disagree. Duplicate types are rejected before any entity allocation or component write. Validation uses bounded stack metadata; entity and component storage may allocate.
This actor recipe authors five components together and updates them once per executed simulation tick, using six fetched entries including the identity:
use ferravex_ecs::{Entity, Error, With, World};
struct Position(f32);
struct Velocity(f32);
struct Health(u32);
struct Faction(u8);
struct Presentation { last_position: f32 }
let mut world = World::new();
let actor = world.try_spawn((
Position(1.0), Velocity(2.0), Health(10), Faction(1),
Presentation { last_position: 1.0 },
))?;
let fixed_dt = 0.5; // Caller invokes this system once per executed tick.
for row in world.query_filtered::<(
Entity, &mut Position, &Velocity, &Health, &Faction, Option<&mut Presentation>,
), With<Faction>>().try_iter() {
let (id, mut position, velocity, health, faction, presentation) = row?;
assert_eq!(id, actor);
if health.0 > 0 && faction.0 == 1 {
position.0 += velocity.0 * fixed_dt;
if let Some(mut presentation) = presentation {
presentation.last_position = position.0;
}
}
}
assert_eq!(world.get::<&Position>(actor)?.0, 2.0);
assert_eq!(world.get::<&Presentation>(actor)?.last_position, 2.0);
world.despawn(actor)?;
assert!(world.is_empty());Nine component entries exceed the ceiling, even if their types are distinct:
ⓘ
use ferravex_ecs::World;
World::new().spawn((0_u8, 0_u16, 0_u32, 0_u64, 0_i8, 0_i16, 0_i32, 0_i64, false));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.