Struct shard_ecs::archetype::Archetype[][src]

pub struct Archetype { /* fields omitted */ }

Implementations

Returns a reference to a specific component.

Safety:
  • Component type [C] must be present in the archetype
  • panics otherwise.

Returns a mutable reference to a specific component.

Safety:
  • Component type [C] must be present in the archetype
  • panics otherwise.

Returns a reference to a specific component.

Safety:
  • Component group type [G] must be a subset of the types in the archetype
  • panics otherwise.

Returns a reference to a specific component.

Safety:
  • Component group type [G] must be a subset of the types in the archetype
  • panics otherwise.

Reads a specific component from the archetype at the given index.

Safety:
  • Component type [C] must be present in the archetype
  • panics otherwise.

Returns a tuple of mutable component slices to the archetype’s data.

Safety:
  • Must be called exactly with the component group contained in the archetype.
  • a compatible group type is also accepted.
  • [G] must have a valid archetype descriptor.

Returns a tuple of component slices to the archetype’s data.

Safety:
  • Must be called exactly with the component group contained in the archetype.
  • a compatible group type is also accepted.
  • [G] must have a valid archetype descriptor.

Returns the slices for the components in [G], provided that archetype itself contains a superset of G. This function is slower than the exact version, use that if an exact type match is known.

Safety:
  • Only call this with subsets of the types stored in the archetype.
  • [G] must have a valid archetype descriptor.

Returns the mutable slices for the components in [G], provided that archetype itself contains a superset of G. This function is slower than the exact version, use that if an exact type match is known.

Safety:
  • Only call this with subsets of the types stored in the archetype.
  • [G] must have a valid archetype descriptor.

Returns the entity slice and the slices for the components in [G], provided that archetype itself contains a superset of G. This function is slower than the exact version, use that if an exact type match is known.

Safety:
  • Only call this with subsets of the types stored in the archetype.
  • [G] must have a valid archetype descriptor.

Returns the entity slice and the mutable slices for the components in [G], provided that archetype itself contains a superset of G. This function is slower than the exact version, use that if an exact type match is known.

Safety:
  • Only call this with subsets of the types stored in the archetype.
  • [G] must have a valid archetype descriptor.

Returns the amount of entities currently stored in the archetype.

Returns the current capacity of the archetype.

Returns whether the archetype is full or not.

Returns a reference to the internal slice storing entity associations.

Returns a mutable reference to the internal slice storing entity associations.

Pushes a given entity/component-tuple into the archetype’s backing memory.

Safety:
  • Must be called exactly with the component group contained in the archetype.
  • a compatible group type is also accepted.
  • Does not call drop on the given entity.
  • Increases the size of the archetype’s memory allocations if required.
  • If resizing fails, this function will panic.

Identical to push_entity_unchecked but does not actually write the entity’s component data. The memory at the the returned index MUST be written with valid component data. The metadata is not set either.

Decrements archetype size by 1, therefore assuming the last entity is moved elsewhere. As such, it does not call drop on the last entity.

Writes a single component into a specific position. Does not call drop on the existing component at index. Panics if called on an archetype that does not contain [C].

Writes a given entity/component-tuple into the archetype’s backing memory.

Safety:
  • Must be called exactly with the component group contained in the archetype.
  • a compatible group type is also accepted.
  • Does not call drop on the given entity.
  • Does not call drop on the entity that already exists at [index].
  • Assumes the underlying backing memory is sized accordingly to fit the data.
  • Does not increase the entity counter.
  • Does not check if [index] is out of bounds or not.

Swaps the entity at [index] and the last entity and drops the now-last entity. This effectively reduces the size of the archetype by 1, dropping the entity at index. And moving the previously last entity to the position at index. If [index] is the last element, simply drops it instead without any swaps occurring. Returns true if a swap occurred, or false if not.

Safety:
  • [index] must be smaller than the amount of entities in the archetype.

Swaps the entity at [index] and the last entity. Makes sure the entity at [index] is at the end of the archetype. If [index] is the last element, does nothing. Returns true if a swap occurred, or false if not.

Safety:
  • [index] must be smaller than the amount of entities in the archetype.

Swaps the entity at [index] and the last entity and returns the now-last entity. This effectively reduces the size of the archetype by 1, returning the entity at index. And moving the previously last entity to the position at index. If [index] is the last element, simply returns it instead without any swaps occurring. Returns true if a swap occurred, or false if not.

Safety:
  • [index] must be smaller than the amount of entities in the archetype.
  • [G] must exactly match the type store in the archetype.
  • Ordering of component in [G] may be different.

Swaps the entities at the provided positions.

Safety:
  • [first] must be smaller than the amount of entities in the archetype.
  • [second] must be smaller than the amount of entities in the archetype.
  • [first] must not be equal to [last].

Calls drop on the entity at [index].

Safety:
  • [index] must be smaller than the amount of entities in the archetype.

Drops all the entities in the archetype. Does not deallocate the memory.

Reads the component data at [index] and returns it.

Safety:
  • [G] must be exactly the type stored in the archetype.
  • a compatible one also works. (i.e. same archetype, different ordering)

Copies common components between two archetypes.

Creates an archetype with the default amount of memory allocated for it. Panics if the provided archetype descriptor is invalid.

Allocates an archetype with a given capacity for storing data into it. Panics if the provided archetype descriptor is invalid. Does not allocate if [capacity] exceeds MAX_ENTITIES_PER_ARCHETYPE. Does not allocate if [capacity] is 0. Panics in case of allocation failures.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.