Struct EcsCommandBuffer

pub struct EcsCommandBuffer { /* private fields */ }
Expand description

Typed, bounded structural changes for one ECS world at a tick boundary. See the module recipe for preparation, query lifetimes and accepted feedback.

Implementations§

§

impl EcsCommandBuffer

pub fn new(command_capacity: usize, spawn_capacity: usize) -> EcsCommandBuffer

Reserves bounded queue/report/map storage. Zero capacities are valid. Construction uses the ordinary allocator and can panic/abort.

pub fn len(&self) -> usize

Number of pending operations, excluding consumed errors and panics.

pub fn is_empty(&self) -> bool

pub fn capacity(&self) -> usize

Pending-operation limit, independent of the epoch spawn-map limit.

pub fn remaining_capacity(&self) -> usize

pub fn spawn_capacity(&self) -> usize

Total accepted-spawn limit per epoch; claiming does not release slots.

pub fn remaining_spawn_capacity(&self) -> usize

pub fn spawn<B>( &mut self, id: u64, bundle: B, ) -> Result<SpawnToken, RejectedBundle<B>>
where B: Bundle + 'static,

Authors a prepared single spawn; full queue takes precedence over map full. Returns a token only after accepting the command and its mapping slot.

pub fn insert<B>( &mut self, id: u64, target: impl Into<EntityTarget>, bundle: B, ) -> Result<(), RejectedBundle<B>>
where B: Bundle + 'static,

Appends a checked insert. Queue capacity is checked before token validity. Ordinary entity liveness is checked at apply by the existing ECS API.

pub fn remove<T>( &mut self, id: u64, target: impl Into<EntityTarget>, ) -> Result<(), EnqueueError>
where T: 'static,

Removes and drops T at apply; absence is an ECS error, not a no-op.

pub fn despawn( &mut self, id: u64, target: impl Into<EntityTarget>, ) -> Result<(), EnqueueError>

Despawns at apply; stale entities are errors, not silently ignored.

pub fn apply_report( &mut self, world: &mut World, limit: usize, policy: CommandFailurePolicy, on_error: impl FnMut(CommandFailure<EcsCommandError>), ) -> Result<EcsApplyReport<'_>, BufferError>

Executes at most limit operations; errors consume budget and commands. Stop/continue and untouched-tail behavior match the shared fallible queue. Each failure is moved synchronously to on_error; no error list is built. Successes are logged before any later command/callback can panic. Both command and callback panics propagate. A spawn is marked failed before invocation, then mapped only on success. No spawn is automatically retried. Only incomplete reset returns Err before doing work.

pub fn last_accepted(&self) -> &[AppliedEntityCommand]

Last flush’s successes, also inspectable after an unwind. A later apply replaces this log. Hosts must avoid emitting the same inspected log twice.

pub fn take_spawn(&mut self, token: &SpawnToken) -> Result<Entity, TokenError>

Claims an accepted spawn even after the report drops or a later unwind. Does not check entity liveness; a subsequent command may have despawned it.

pub fn reset(&mut self) -> Result<(), BufferError>

Cancels pending work, invalidates every token and clears mappings/logs. Does not despawn accepted entities. Retains all storage and buffer identity. Epoch advancement is checked before mutation and never wraps. Tokens keep the reference-counted identity alive, so buffer drop/recreation cannot revive them. Before dropping payloads the buffer enters reset-incomplete state; if a destructor panics, the untouched tail is disabled until another reset completes. No cancellation callback runs; owned payloads are dropped.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.