Files
medicallib_rust/MIGRATION.md
T
2025-09-21 02:14:44 -07:00

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 Organ trait (src/organs/mod.rs)
  • Organ implementations -> dedicated structs per organ (e.g., Heart, Lungs)
  • initializePatient() -> Patient::initialize_default() or Patient::with_heart(leads)
  • updatePatient(dt) -> Patient::update(dt_seconds)
  • Template organ getters -> Patient::find_organ_typed::<T>() and find_organ_typed_mut::<T>()
  • C API -> feature ffi, header ffi/medicallib.h, with MLPatient* opaque handle

Notable differences:

  • Memory safety and ownership are enforced by Rust; no raw pointer ownership in the library
  • Errors use thiserror with Result<T, MedicalError>
  • Logging is not emitted by the library by default; use tracing in binaries/examples
  • Additional organ systems are modeled with simplified states as a baseline