*.system.rs

Any file ending in .system.rs under src/ is a system: one function marked #[system].

// src/room/warmth.system.rs — the system room/warmth
use cognet::prelude::*;
use crate::schema::room::room::{Heating, Temperature};

use super::comfort;

#[system(reads = ["temperature"], writes = ["heating"])]
fn warmth(run: &mut Run) -> Result<(), Fault> {
    for (room, temperature) in ecs.all::<Temperature>("temperature")? {
        ecs.set(&room).put("heating", Heating { on: comfort::cold(&temperature) })?;
    }
    Ok(())
}

#[system] takes the same fields as defineSystem. Inside, ecs is the run's world:

CallDoes
ecs.first::<T>(c)?c on the first entity holding it
ecs.get::<T>(entity, c)?c on one entity
ecs.all::<T>(c)?every (entity, value)
ecs.set(entity).put(c, value)?write — chain more .puts
run.since::<T>(c)?everything written to a streamed c since the last run

Code is mounted where it sits

Every .rs under the cognet is a module at its path. src/room/comfort.rs is super::comfort from the system beside it; library/vec/vec.rs is crate::library::vec::vec from anywhere; component types are at crate::schema::…, mirroring types/. No mod declarations to write.

Errors

Return Err(Fault::new("why")) and the run fails like any other, recorded with its message. A panic is caught and becomes a fault too.

Runs on

In the same process as the engine — no copying. Large arrays arrive as memory. Crates go in Cargo.toml; a cognet with Rust needs cargo installed.