f4398948644e933b056e5f22b0b912ef3e9eedeb
- Implement rich state machines and hemodynamic/metabolic models across organs (brain, heart, lungs, kidneys, liver, stomach, intestines, pancreas, gallbladder, spleen, spinal cord, bladder, esophagus) - Add new enums for organ phases/states (e.g., SleepStage, VentilatoryState, CardiacRhythmState, RenalAutoregulationState, GastricPhase, etc.) - Extend organ structs with explicit physiology fields; rewrite update() loops and summaries to reflect realistic dynamics - Wire inter-organ signaling in Patient (oxygenation, CPP, autonomic, hormones, bile, bile acids, urine→bladder, gastric emptying→intestines) using a relax_value smoothing helper - Minor formatting in build.rs BREAKING CHANGE: public organ structs gained/renamed fields and updated summaries; code using struct literals or prior field names will break. Use constructors (e.g., new()) and updated fields; summary outputs have changed.
medicallib_rust
MedicalSim core library rewrite in Rust.
- Safe, minimal API for medical simulation primitives
- Optional
serdefeature for serialization - Optional
ffifeature to expose a stable C ABI (cdylib)
Build
- Build:
cargo build(tests:cargo test) - FFI build:
cargo build --features ffi --release - Format/Lint:
cargo fmt --allandcargo clippy -D warnings
Examples
- Rust:
cargo run --example usageandcargo run --example patient - C FFI: see
examples/c/ffi_example.c, header inffi/medicallib.h
FFI ABI
- Opaque
MLPatienthandle - Functions:
medicallib_bmi,ml_patient_new/free/update,ml_patient_summary,ml_patient_organ_summary - All allocated strings must be freed with
ml_string_free
Version Matrix
- Rust 1.70+ (Edition 2021)
- OS: Linux, macOS, Windows (see GitHub Actions CI)
Docs
- Architecture:
ARCHITECTURE.md - Migration (C++ -> Rust):
MIGRATION.md - C/C++ install:
INSTALL.md
Packaging (binary distribution)
- Linux/macOS: run
../scripts/package.sh [target-triple]frommedicallib_rust/(ormake package). - Windows: run
..\scripts\package.ps1 [target-triple]frommedicallib_rust\. - Artifacts are placed in
medicallib_rust/dist/as both.tar.gz(Unix) and.zip.
CI: GitHub + Gitea
- GitHub Actions workflow:
.github/workflows/ci.yml - Gitea Actions workflow:
.gitea/workflows/ci.yml
Description