1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Deterministic simulation test harness for concurrent systems.
//!
//! This crate is a facade that re-exports the core simulation testing framework from
//! [`simvar_harness`] and optional utilities from [`simvar_utils`]. It provides a unified
//! interface for writing deterministic tests of distributed systems and concurrent applications.
//!
//! # Features
//!
//! * **Deterministic execution** - Same seed produces identical simulation results
//! * **Host and client actors** - Model persistent services (hosts) and ephemeral clients
//! * **Simulation lifecycle hooks** - Customize behavior at key points via [`SimBootstrap`]
//! * **Built-in TUI** - Optional terminal UI for monitoring simulation progress (with `tui` feature)
//! * **Parallel execution** - Run multiple simulation runs concurrently
//! * **Cancellation support** - Graceful shutdown with Ctrl-C handling
//!
//! # Example
//!
//! ```rust,no_run
//! use simvar::{run_simulation, SimBootstrap, Sim, SimConfig};
//!
//! struct MyBootstrap;
//!
//! impl SimBootstrap for MyBootstrap {
//! fn build_sim(&self, config: SimConfig) -> SimConfig {
//! config
//! }
//!
//! fn on_start(&self, sim: &mut impl Sim) {
//! // Spawn a host actor
//! sim.host("server", || async {
//! // Server logic here
//! Ok(())
//! });
//!
//! // Spawn a client actor
//! sim.client("client", async {
//! // Client logic here
//! Ok(())
//! });
//! }
//! }
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let results = run_simulation(MyBootstrap)?;
//! # Ok(())
//! # }
//! ```
//!
//! # Feature Flags
//!
//! * `all` (default) - Enable all features
//! * `async` - Async runtime support
//! * `database` - Database simulation
//! * `fs` - Filesystem simulation
//! * `http` - HTTP client/server simulation
//! * `mdns` - mDNS simulation
//! * `random` - Random number generation simulation
//! * `tcp` - TCP connection simulation
//! * `telemetry` - Telemetry support
//! * `time` - Time simulation
//! * `tui` - Terminal UI for simulation visualization
//! * `upnp` - `UPnP` simulation
//! * `utils` - Simulation utilities module
//! * `web-server` - Web server simulation
//! * `pretty_env_logger` - Pretty logging output
//!
//! # Environment Variables
//!
//! * `SIMULATOR_RUNS` - Number of simulation runs to execute (default: 1)
//! * `SIMULATOR_MAX_PARALLEL` - Maximum parallel runs (default: number of CPUs)
//! * `NO_TUI` - Disable terminal UI when set
/// Simulation utilities module.
///
/// Provides utility functions for managing worker threads and cancellation tokens
/// in simulation environments. Includes thread-local and global cancellation support
/// for gracefully terminating simulations and async operations.
///
/// Requires the `utils` feature flag.
pub use simvar_utils as utils;
/// Core simulation harness APIs.
///
/// Re-exports all public types, traits, and functions from [`simvar_harness`],
/// including [`run_simulation`], [`Sim`], [`SimBootstrap`], and [`SimConfig`].
pub use *;