pub trait ChildBuild {
type SpawnOutput<'a>: BuildChildren
where Self: 'a;
// Required methods
fn spawn(&mut self, bundle: impl Bundle) -> Self::SpawnOutput<'_>;
fn spawn_empty(&mut self) -> Self::SpawnOutput<'_>;
fn parent_entity(&self) -> Entity;
fn enqueue_command<C: Command>(&mut self, command: C) -> &mut Self;
}Expand description
Trait for building children entities and adding them to a parent entity. This is used in
implementations of BuildChildren as a bound on the Builder
associated type. The closure passed to BuildChildren::with_children accepts an
implementation of ChildBuild so that children can be spawned via ChildBuild::spawn.
Required Associated Types§
Sourcetype SpawnOutput<'a>: BuildChildren
where
Self: 'a
type SpawnOutput<'a>: BuildChildren where Self: 'a
Spawn output type. Both spawn and spawn_empty return
an implementation of this type so that children can be operated on via method-chaining.
Implementations of ChildBuild reborrow self when spawning entities (see
Commands::spawn_empty and World::get_entity_mut). Lifetime 'a corresponds to this
reborrowed self, and Self outlives it.
Required Methods§
Sourcefn spawn(&mut self, bundle: impl Bundle) -> Self::SpawnOutput<'_>
fn spawn(&mut self, bundle: impl Bundle) -> Self::SpawnOutput<'_>
Sourcefn spawn_empty(&mut self) -> Self::SpawnOutput<'_>
fn spawn_empty(&mut self) -> Self::SpawnOutput<'_>
Sourcefn parent_entity(&self) -> Entity
fn parent_entity(&self) -> Entity
Returns the parent entity.
Sourcefn enqueue_command<C: Command>(&mut self, command: C) -> &mut Self
fn enqueue_command<C: Command>(&mut self, command: C) -> &mut Self
Adds a command to be executed, like Commands::queue.
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.