Skip to main content

Archetype

Struct Archetype 

Source
pub struct Archetype { /* private fields */ }
Expand description

A group of entities that share the same set of component types.

Columns are independently borrowable — no double-borrow of a HashMap needed for multi-component queries.

Implementations§

Source§

impl Archetype

Source

pub fn id(&self) -> ArchetypeId

The archetype’s ID.

Source

pub fn layout(&self) -> &ArchetypeLayout

The archetype’s layout.

Source

pub fn len(&self) -> usize

Number of entities in this archetype.

Source

pub fn is_empty(&self) -> bool

Whether this archetype has no entities.

Source

pub fn entity_at(&self, row: usize) -> Entity

The entity stored at row.

Source

pub fn entities(&self) -> &[Entity]

Slice of all entities in this archetype.

Source

pub fn column<T: Send + Sync + 'static>(&self) -> Option<&Column<T>>

Get a typed column reference. Returns None if the type isn’t in this archetype’s layout.

Source

pub fn column_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut Column<T>>

Get a typed column mutable reference.

Source

pub fn column_raw(&self, type_id: TypeId) -> Option<&dyn AnyColumn>

Get a type-erased column reference.

Source

pub fn column_raw_mut(&mut self, type_id: TypeId) -> Option<&mut dyn AnyColumn>

Get a type-erased column mutable reference.

Source

pub fn entities_and_column_mut<T: Send + Sync + 'static>( &mut self, ) -> Option<(&[Entity], &mut Column<T>)>

Split-borrow: shared entity slice + exclusive column reference.

Returns None if the archetype doesn’t contain type T.

Source

pub fn entities_and_two_columns_mut<A, B>( &mut self, ) -> Option<(&[Entity], &mut Column<A>, &mut Column<B>)>
where A: Send + Sync + 'static, B: Send + Sync + 'static,

Split-borrow: shared entity slice + two exclusive column references.

Panics if A == B. Returns None if either type is absent.

Source

pub fn entities_and_three_columns_mut<A, B, C>( &mut self, ) -> Option<(&'_ [Entity], &'_ mut Column<A>, &'_ mut Column<B>, &'_ mut Column<C>)>
where A: Send + Sync + 'static, B: Send + Sync + 'static, C: Send + Sync + 'static,

Split-borrow: shared entity slice + three exclusive column references.

Panics if any two queried types are the same. Returns None if any type is absent from this archetype.

Source

pub fn edge(&self, type_id: TypeId) -> Option<&ArchetypeEdge>

Get the edge cache entry for a component type.

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 = !

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.