960 B
960 B
Migration Guide: C++ MedicalSim -> medicallib_rust
This guide summarizes the mapping and differences between the legacy C++ library and the new Rust core.
- Organ base class -> Rust
Organtrait (src/organs/mod.rs) - Organ implementations -> dedicated structs per organ (e.g., Heart, Lungs)
initializePatient()->Patient::initialize_default()orPatient::with_heart(leads)updatePatient(dt)->Patient::update(dt_seconds)- Template organ getters ->
Patient::find_organ_typed::<T>()andfind_organ_typed_mut::<T>() - C API -> feature
ffi, headerffi/medicallib.h, withMLPatient*opaque handle
Notable differences:
- Memory safety and ownership are enforced by Rust; no raw pointer ownership in the library
- Errors use
thiserrorwithResult<T, MedicalError> - Logging is not emitted by the library by default; use
tracingin binaries/examples - Additional organ systems are modeled with simplified states as a baseline