Implementation & Test Code¶
The Rust implementation captures traceability via doc comments and stable public APIs. |
The native test runner writes test_results.xml in JUnit format and maps to the TEST_* needs. |
This example keeps documentation (*.rst) next to the Rust source and test artifacts for end-to-end traceability. |
Code Organization¶
This TSIM implementation is written in Rust and keeps the same requirement IDs as the reference example.
examples/rust_hello_world/
├── Cargo.toml
├── src/
│ ├── lib.rs # Implementation with requirement IDs in doc comments
│ └── bin/
│ └── junit_tests.rs # Native test runner writing JUnit XML
├── test_results.xml # Generated by ./build-and-test.sh
└── build-and-test.sh
Traceability in Rust Code¶
In Rust projects, requirement traceability is typically captured via:
module-level doc comments (//! REQ_*)
function-level doc comments (/// REQ_*)
explicit mapping tables in the documentation
The public API in src/lib.rs maps directly to:
(FR) The module shall read ... (REQ_FUNC_001) (ADC conversion)
(FR) The module shall filte... (REQ_FUNC_002) (5-sample moving average)
(FR) The module shall trigg... (REQ_FUNC_003) / (FR) The module shall trigg... (REQ_FUNC_004) (threshold + hysteresis)
Building & Running Tests¶
cd examples/rust_hello_world
cargo build
cargo run --bin junit_tests -- test_results.xml
Then build the documentation (imports test_results.xml):
osqar build-docs --project examples/rust_hello_world