pub trait System:
Any
+ Debug
+ Send {
// Required method
fn step(&mut self, ctx: &mut PipelineContext<'_>) -> StepResult;
// Provided methods
fn init(&mut self, _ctx: &mut PipelineContext<'_>) { ... }
fn access(&self) -> Access { ... }
}Expand description
System – has behavior, receives a PipelineContext each tick. Every system
is internal engine code: World::start constructs it from world components
(via the system’s own new(..)), so a system is never loaded from or
written to a blob. init runs once at World::start; step runs every
tick.
A world holds its systems as dyn System, so the trait is object-safe.
Send is what lets a built world move to the simulation thread, and Any
is what lets a caller holding the world reach one system as its own type
(the cn debug / cn editor hot-reload drive).
Required Methods§
Sourcefn step(&mut self, ctx: &mut PipelineContext<'_>) -> StepResult
fn step(&mut self, ctx: &mut PipelineContext<'_>) -> StepResult
Run once per tick.
Provided Methods§
Sourcefn init(&mut self, _ctx: &mut PipelineContext<'_>)
fn init(&mut self, _ctx: &mut PipelineContext<'_>)
Run once at World::start, before the first step.
Sourcefn access(&self) -> Access
fn access(&self) -> Access
The data step may touch, consulted once when the schedule is built
(after init, so a data-dependent system can compute it from its
compiled state). The default claims everything: an undeclared system is
ordered against all others and never runs concurrently, which is always
safe. Declaring narrower access is what admits a system to shared waves
and to debug-build access validation.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".