Crate hv_ecs

Crate hv_ecs 

Source
Expand description

A handy ECS

hecs provides a high-performance, minimalist entity-component-system (ECS) world. It is a library, not a framework. In place of an explicit “System” abstraction, a World’s entities are easily queried from regular code. Organize your application however you like!

In order of importance, hecs pursues:

  • fast traversals
  • a simple interface
  • a small dependency closure
  • exclusion of externally-implementable functionality
let mut world = World::new();
// Nearly any type can be used as a component with zero boilerplate
let a = world.spawn((123, true, "abc"));
let b = world.spawn((42, false));
// Systems can be simple for loops
for (id, (number, &flag)) in world.query_mut::<(&mut i32, &bool)>() {
  if flag { *number *= 2; }
}
// Random access is simple and safe
assert_eq!(*world.get::<i32>(a).unwrap(), 246);
assert_eq!(*world.get::<i32>(b).unwrap(), 42);

Structs§

Archetype
A collection of entities having the same component types
ArchetypesGeneration
Determines freshness of information derived from World::archetypes
Batch
A sequence of entities yielded by BatchedIter
BatchIncomplete
Error indicating that a ColumnBatchBuilder was missing components
BatchWriter
Handle for appending components
BatchedIter
Batched version of QueryIter
BuiltEntity
The output of an EntityBuilder, suitable for passing to World::spawn or World::insert
Cloneable
Type parameter for EntityBuilders with cloneable components
ColumnBatch
A collection of component data for entities with the same component types
ColumnBatchBuilder
An incomplete collection of component data for entities with the same component types
ColumnBatchType
A collection of component types
DynamicComponent
A handle to a component of type T returned from a dynamic query, obtained by DynamicItem::take.
DynamicItem
A set of components returned from some dynamic query, which belong to some entity satisfying that query.
DynamicItemRef
Immutable borrow of a DynamicComponent.
DynamicItemRefMut
Mutable borrow of a DynamicComponent.
DynamicQuery
A dynamic query; the dynamic equivalent of the Query trait. Used with World::dynamic_query and World::dynamic_query_one.
DynamicQueryBorrow
A borrow of a World sufficient to execute some dynamic query.
DynamicQueryIter
Iterator over the set of entities which satisfy some DynamicQuery.
DynamicWith
A dynamic query transformer which requires that entities satisfying some dynamic query also have some component type, without needing to borrow it.
DynamicWithout
A dynamic query transformer which requires that entities satisfying the subquery also not contain some component type.
Entity
Lightweight unique ID, or handle, of an entity
EntityBuilder
Helper for incrementally constructing a bundle of components with dynamic component types
EntityRef
Handle to an entity with any component types
Iter
Iterator over all of a world’s entities
MissingComponent
Error indicating that an entity did not have a required component
NoSuchEntity
Error indicating that no entity with a particular ID exists
PreparedQuery
A prepared query can be stored independently of the World to amortize query set-up costs.
PreparedQueryBorrow
Combined borrow of a PreparedQuery and a World
PreparedQueryIter
Iterates over all entities matching a PreparedQuery
QueryBorrow
A borrow of a World sufficient to execute the query Q
QueryIter
Iterator over the set of entities with the components in Q
QueryMut
A query builder that’s convertible directly into an iterator
QueryOne
A borrow of a World sufficient to execute the query Q on a single entity
Ref
Shared borrow of an entity’s component
RefMut
Unique borrow of an entity’s component
ReusableBuiltEntity
A collection of components that implement Clone
Satisfies
A query that yields true iff an entity would satisfy the query Q
SpawnBatchIter
Entity IDs created by World::spawn_batch
SpawnColumnBatchIter
Iterator over Entitys spawned by World::spawn_column_batch()
With
Query transformer skipping entities that do not have a T component
Without
Query transformer skipping entities that have a T component
World
An unordered collection of entities, each having any number of distinctly typed components

Enums§

Access
Type of access a Query may have to an Archetype
ComponentError
Errors that arise when accessing components
Or
Holds an L, or an R, or both
QueryOneError
Errors that arise when querying a single entity

Traits§

Bundle
A statically typed collection of components
Component
Types that can be components, implemented automatically for all Send + Sync + 'static types
DynamicBundle
A dynamically typed collection of components
Query
A collection of component types to fetch from a World

Type Aliases§

QueryItem
Type of values yielded by a query