31a0b8a485
Multi-Platform CI / test-platforms (ubuntu-22.04) (push) Successful in 18s
Multi-Platform CI / test-platforms (windows-latest) (push) Successful in 18s
Multi-Platform CI / Package for Linux x86_64 (push) Has been skipped
Multi-Platform CI / Package for Windows x86_64 (push) Has been skipped
Multi-Platform CI / Create GitHub Release (push) Has been skipped
- add C FFI enums MLBladderPhase, MLMetabolicState, MLPerfusionState - add C FFI structs MLBloodstreamMetrics and MLBladderMetrics - add ml_patient_bloodstream_metrics and ml_patient_bladder_metrics to populate metrics for a patient (mirrored in src/ffi.rs) - update examples/c/ffi_example.c to print new metrics - add tests for FFI metrics (tests/ffi.rs) organ model expansions - bloodstream: add metrics() snapshot and detailed physiology: plasma proteins/oncotic pressure, lymph return, RBC cohort tracking, erythropoiesis/clearance with HIF, iron/folate/B12 stores, platelets, coagulation/fibrinolysis, immune cell counts, complement, acid–base - bladder: introduce adaptive compliance, reflex gating, cortical/voluntary modulators, safety indices; add metrics(), summary, and unit tests - brain: add homeostatic drives (respiratory, thirst, hunger, thermo, pain), brainstem nuclei (NTS/RVLM/CVLM, nAmb/DMV, RTN), sleep cycle timing, cerebrovascular autoregulation; wire drives into autonomic control - heart: add phase-based cycle (valves and atria), conduction system, RAAS regulation, improved coronary perfusion - intestines: add micronutrient absorption feeding erythropoiesis patient coupling - expose Patient::bloodstream_metrics() and ::bladder_metrics() - integrate new organ signals (kidney osmolality, spleen culling, liver proteins) and brain–lung/continence control pathways - re-export BladderMetrics and BloodstreamMetrics in lib.rs note - existing FFI remains compatible; this is a surface addition - ffi/medicallib.h kept in sync with src/ffi.rs
53 lines
1.7 KiB
Rust
53 lines
1.7 KiB
Rust
#[cfg(feature = "ffi")]
|
|
#[test]
|
|
fn ffi_bmi_and_patient() {
|
|
let mut out: f32 = 0.0;
|
|
let rc = medicallib_rust::ffi::medicallib_bmi(70.0, 1.75, &mut out as *mut f32);
|
|
assert_eq!(rc, medicallib_rust::ffi::ML_OK);
|
|
assert!(out > 10.0);
|
|
|
|
use std::ffi::CString;
|
|
let id = CString::new("ffi-test").unwrap();
|
|
let p = medicallib_rust::ffi::ml_patient_new(id.as_ptr());
|
|
assert!(!p.is_null());
|
|
let _ = medicallib_rust::ffi::ml_patient_update(p, 0.1);
|
|
let s = medicallib_rust::ffi::ml_patient_summary(p);
|
|
assert!(!s.is_null());
|
|
medicallib_rust::ffi::ml_string_free(s);
|
|
medicallib_rust::ffi::ml_patient_free(p);
|
|
}
|
|
|
|
#[cfg(feature = "ffi")]
|
|
#[test]
|
|
fn ffi_errors() {
|
|
// Null out pointer arguments should error gracefully
|
|
let rc = medicallib_rust::ffi::medicallib_bmi(70.0, 1.75, std::ptr::null_mut());
|
|
assert_eq!(rc, medicallib_rust::ffi::ML_EINVAL);
|
|
let p = medicallib_rust::ffi::ml_patient_new(std::ptr::null());
|
|
assert!(p.is_null());
|
|
// Summary with null patient returns null
|
|
let s = medicallib_rust::ffi::ml_patient_summary(std::ptr::null());
|
|
assert!(s.is_null());
|
|
}
|
|
|
|
#[cfg(feature = "ffi")]
|
|
#[test]
|
|
fn ffi_bloodstream_metrics() {
|
|
use medicallib_rust::ffi::*;
|
|
use std::ffi::CString;
|
|
|
|
let id = CString::new("ffi-blood").unwrap();
|
|
let p = ml_patient_new(id.as_ptr());
|
|
assert!(!p.is_null());
|
|
|
|
let mut metrics = std::mem::MaybeUninit::<MLBloodstreamMetrics>::uninit();
|
|
assert_eq!(ml_patient_update(p, 0.5), ML_OK);
|
|
let rc = ml_patient_bloodstream_metrics(p, metrics.as_mut_ptr());
|
|
assert_eq!(rc, ML_OK);
|
|
let metrics = unsafe { metrics.assume_init() };
|
|
assert!(metrics.oncotic_pressure_mm_hg > 15.0);
|
|
assert!(metrics.rbc_mature_fraction > 0.4);
|
|
ml_patient_free(p);
|
|
}
|
|
|