Skip to main content

moirai/
lib.rs

1//! Moirai is a single-threaded, `no_std + alloc` entity-component-system library.
2//!
3//! The public surface is a set of concept-level namespaces, curated root re-exports,
4//! and a smaller system-authoring prelude. Implementation modules such as allocators,
5//! registries, storage engines, command queues, and schedule runners stay private.
6//!
7//! # Crate root and prelude admission
8//!
9//! Common application, world, schedule, query, bundle, state, and time vocabulary is
10//! available at the crate root. [`prelude`] contains the subset normally needed to
11//! author systems. Advanced construction helpers such as [`world::BundleWriter`] stay
12//! in their semantic namespace.
13//!
14//! # Learn by example
15//!
16//! [`examples`] is the canonical ordered learning path. Its stable, runnable doctests
17//! progress from a first app through scheduling, queries, and deterministic replay.
18//!
19//! # Privacy boundary
20//!
21//! Internal modules are not reachable from downstream crates:
22//!
23//! ```compile_fail
24//! use moirai::entity::allocator;
25//! ```
26//!
27//! ```compile_fail
28//! use moirai::storage;
29//! ```
30//!
31//! ```compile_fail
32//! use moirai::component::registry;
33//! ```
34
35#![no_std]
36#![forbid(unsafe_code)]
37
38extern crate alloc;
39
40#[cfg(feature = "std")]
41extern crate std;
42
43mod app;
44mod command;
45pub mod diagnostics;
46pub mod event;
47pub mod examples;
48mod operation;
49pub mod prelude;
50pub mod query;
51mod resource;
52mod revision;
53pub mod schedule;
54pub mod state;
55mod storage;
56mod time;
57
58#[cfg(feature = "bench-internals")]
59#[doc(hidden)]
60pub mod bench_internals;
61
62mod entity;
63
64pub mod component;
65pub mod math;
66pub mod world;
67
68#[cfg(feature = "testkit")]
69pub mod testkit;
70
71pub use app::{App, AppBuilder, AppError, AppFault, BuildError};
72pub use component::{ComponentId, ComponentOptions, StorageKind};
73pub use entity::EntityId;
74pub use event::{
75    ComponentAdded, ComponentRemoved, EventId, EventOptions, EventReader, EventReaderStart,
76    EventRegistrationError, EventRetention,
77};
78pub use math::Q16;
79pub use operation::StageOperation;
80pub use query::{
81    ExactIdPolicy, PreparedQuery1, PreparedQuery2, Query1, Query2, QueryCommands, QueryCursor,
82    QueryEffects, QueryError, QueryPolicy, QuerySpec, QueryWindow,
83};
84pub use revision::{Revision, RevisionExhausted, RevisionKey};
85pub use schedule::stage;
86pub use schedule::{
87    Condition, ConditionError, FlushMode, Schedule, ScheduleBuilder, ScheduleError, StageId,
88    System, SystemId, SystemInitContext, SystemSet, UpdatePlan,
89};
90pub use state::{apply, on_enter, on_exit, on_transition, State, StateError};
91pub use time::{
92    ChangeTick, FixedConfig, FixedDebtCoalesced, FixedDebtDropped, FixedDebtPolicy, FixedStep,
93    WorldTick,
94};
95pub use world::{
96    Bundle, Commands, DenseEntityScratch, DynamicBundle, EntityScratchError, World, WorldBuilder,
97    WorldError,
98};