Module sim::simulator[][src]

The simulator module provides the mechanics to orchestrate the models and connectors via discrete event simulation. The specific formalism for simulation execution is the Discrete Event System Specification. User interaction is also captured in this module - simulation stepping and input injection.

Simulation and WebSimulation are used for Rust- and npm-based projects, respectively. The Simulation methods use the associated struct types directly, while the WebSimulation provides an interface with better JS/WASM compatibility.

Most simulation analysis will involve the collection, transformation, and analysis of messages. The step, step_n, and step_until methods return the messages generated during the execution of the simulation step(s), for use in message analysis.



Connectors are configured to connect models through their ports. During simulation, models exchange messages (as per the Discrete Event System Specification) via these connectors.


Messages are the mechanism of information exchange for models in a a simulation. The message must contain origin information (source model ID and source model port), destination information (target model ID and target model port), and the text/content of the message.


The Simulation struct is the core of sim, and includes everything needed to run a simulation - models, connectors, and a random number generator. State information, specifically global time and active messages are additionally retained in the struct.


The WebSimulation provides JS/WASM-compatible interfaces to the core Simulation struct. For additional insight on these methods, refer to the associated Simulation methods. Errors are unwrapped, instead of returned, in the WebSimulation methods.