Expand description
Moirai is a single-threaded, no_std + alloc entity-component-system library.
The public surface is a set of concept-level namespaces, curated root re-exports, and a smaller system-authoring prelude. Implementation modules such as allocators, registries, storage engines, command queues, and schedule runners stay private.
§Crate root and prelude admission
Common application, world, schedule, query, bundle, state, and time vocabulary is
available at the crate root. prelude contains the subset normally needed to
author systems. Advanced construction helpers such as world::BundleWriter stay
in their semantic namespace.
§Learn by example
examples is the canonical ordered learning path. Its stable, runnable doctests
progress from a first app through scheduling, queries, and deterministic replay.
§Privacy boundary
Internal modules are not reachable from downstream crates:
use moirai::entity::allocator;use moirai::storage;use moirai::component::registry;Re-exports§
pub use component::ComponentId;pub use component::ComponentOptions;pub use component::StorageKind;pub use event::ComponentAdded;pub use event::ComponentRemoved;pub use event::EventId;pub use event::EventOptions;pub use event::EventReader;pub use event::EventReaderStart;pub use event::EventRegistrationError;pub use event::EventRetention;pub use math::Q16;pub use query::ExactIdPolicy;pub use query::PreparedQuery1;pub use query::PreparedQuery2;pub use query::Query1;pub use query::Query2;pub use query::QueryCommands;pub use query::QueryCursor;pub use query::QueryEffects;pub use query::QueryError;pub use query::QueryPolicy;pub use query::QuerySpec;pub use query::QueryWindow;pub use schedule::stage;pub use schedule::Condition;pub use schedule::ConditionError;pub use schedule::FlushMode;pub use schedule::Schedule;pub use schedule::ScheduleBuilder;pub use schedule::ScheduleError;pub use schedule::StageId;pub use schedule::System;pub use schedule::SystemId;pub use schedule::SystemInitContext;pub use schedule::SystemSet;pub use schedule::UpdatePlan;pub use state::apply;pub use state::on_enter;pub use state::on_exit;pub use state::on_transition;pub use state::State;pub use state::StateError;pub use world::Bundle;pub use world::Commands;pub use world::DenseEntityScratch;pub use world::DynamicBundle;pub use world::EntityScratchError;pub use world::World;pub use world::WorldBuilder;pub use world::WorldError;
Modules§
- component
- Component registration, storage policy, and dense registry-local handles.
- diagnostics
- Platform-neutral diagnostic observer contracts for
crate::Appexecution. - event
- Typed event registration, retention policy, and independent readers.
- examples
- Progressive, runnable lessons for learning Moirai through its public API.
- math
- Deterministic fixed-point helpers for host-side simulation math.
- prelude
- System-authoring essentials for Moirai hosts.
- query
- Query selection, traversal, caching, and safe mutation.
- schedule
- Deterministic ECS schedule: stages, systems, conditions, and deferred flush policy.
- state
- Explicit host state machine backed by a
crate::world::Worldresource. - testkit
- Deterministic replay, step records, drivers, and report comparison for host tests.
- world
- ECS
World: entities, components, resources, events, and deferredCommands.
Structs§
- App
- Runnable ECS host pairing one
Worldwith one compiledSchedule. - AppBuilder
- Checked application construction: world seeding, schedule authoring, observer wiring.
- AppFault
- Terminal execution record retained after the first fault.
- Change
Tick - Monotonic world change counter for component/resource mutation metadata.
- Entity
Id - Opaque entity handle relative to one
crate::world::World. - Fixed
Config - Host-provided fixed timestep: interval, substep cap, and debt policy.
- Fixed
Debt Coalesced - Whole fixed intervals represented by one coalesced FixedUpdate run. Whole fixed intervals combined into one coalesced FixedUpdate run.
- Fixed
Debt Dropped - Whole fixed intervals discarded when debt exceeds the substep cap.
- Fixed
Step - Fixed simulation substep identity while FixedUpdate runs.
- Revision
- A checked monotonic revision counter.
- Revision
Exhausted - Returned when a
Revisioncannot advance without overflowing. - Revision
Key - A fixed-width collection of revisions suitable for cache keys.
- World
Tick - Monotonic frame counter advanced once per successful Update pass.
Enums§
- AppError
- Recoverable preflight failures and terminal execution faults for
App. - Build
Error - Schedule construction failure before first execution.
- Fixed
Debt Policy - Policy used when a frame contains more whole fixed intervals than
FixedConfig::max_substeps. - Stage
Operation - Which
crate::Appoperation owns a stage, frame channel, or structural command surface.