Skip to main content

Commands

Struct Commands 

Source
pub struct Commands<'w> {
    world: &'w World,
    scope: Entity,
}
Expand description

A queue of structural changes, all of them in one scope.

The queue lives in the world, so deferring a spawn from a callback to the driver needs no channel.

Fields§

§world: &'w World§scope: Entity

Implementations§

Source§

impl<'w> Commands<'w>

Source

pub(crate) fn new(world: &'w World, scope: Entity) -> Self

Source

pub fn scope(&self) -> Entity

The scope every command of this queue lands in.

Source

pub fn spawn<B: Bundle + 'static>(&self, bundle: B) -> Entity

Queue a spawn of bundle in this scope and return its handle.

The handle is reserved now and refers to a live entity once the queue is applied. Its name comes from the bundle: a type of the caller’s own names it after itself, and a bundle! after the source position that wrote the bundle, so a queued spawn names the code that wrote the bundle rather than the place that queued it.

Source

pub fn spawn_named<B: Bundle + 'static>( &self, name: &'static str, bundle: B, ) -> Entity

Queue a spawn of bundle in this scope under name.

Commands::spawn names the entity after the bundle itself; this is for the objects whose name has to say more than that does.

Source

pub fn despawn(&self, entity: Entity)

Queue the despawn of entity and its subtree.

A refusal is answered when the queue is applied, not when it is filled: the queue is filled from a callback that holds a shared world and has nobody to answer, and the scope it was filled from is the only thing it can say about ownership. World::apply reports the first refusal it meets and keeps going.

Queue a relink of child into parent.

The refusal is answered when the queue is applied: both ends have to be the queueing scope’s to move, nobody moves a root or the shared scope itself, and no relink may hang a scope under its own child. World::apply reports the first refusal it meets and keeps going.

Queue a detach of child into this queue’s scope.

The refusal is answered when the queue is applied: an entity in the shared subtree moves only for the root, and the queueing scope may only detach what it owns. Detaching what is already here is the thing asked for, so it is answered with Ok(()).

Source

pub fn push<C: Command + CommandErase>(&self, command: C)

Queue a command.

Trait Implementations§

Source§

impl<'w> Clone for Commands<'w>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'w> Copy for Commands<'w>

Source§

impl Debug for Commands<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'w> !RefUnwindSafe for Commands<'w>

§

impl<'w> !Send for Commands<'w>

§

impl<'w> !Sync for Commands<'w>

§

impl<'w> !UnwindSafe for Commands<'w>

§

impl<'w> Forget for Commands<'w>

§

impl<'w> Freeze for Commands<'w>

§

impl<'w> Unpin for Commands<'w>

§

impl<'w> UnsafeUnpin for Commands<'w>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Component for T
where T: 'static,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more