5cf6bbda48d82b86bc4db225a26bd53831271c4c
Introduce OrganType::Bloodstream and new organ module, exporting
Bloodstream, PerfusionState, and MetabolicState.
- Patient:
- initialize_default now attaches a bloodstream model
- add with_bloodstream() builder and with_organ support
- update() couples bloodstream with heart, lungs, brain, spinal cord,
kidneys, liver, pancreas, stomach, intestines, gallbladder,
esophagus, bladder, and spleen
- bloodstream ingests hemodynamics, respiratory exchange, renal,
hepatic, splenic, and nutrient feedback; propagates perfusion and
metabolic signals back to organs
- blood metrics (SpO2, hemoglobin, hematocrit, glucose) can be driven
by bloodstream
- Signals:
- Lungs: add O2 delivery, CO2 elimination, V/Q ratio
- Liver: add detox and ammonia clearance
- Kidneys: add plasma volume, urea excretion, erythropoietin
- FFI:
- add ML_ORGAN_BLOODSTREAM (Rust and C header) and mapping in
ml_patient_organ_summary
- Examples/Tests:
- demo monitors "Bloodstream"
- add tests for bloodstream coupling and organ discovery
- lib tests updated to include Bloodstream
Rationale: centralize systemic transport and inter-organ homeostasis for
richer physiology simulation and expose it to C consumers via FFI.
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