b5b6619118
Adopt cbindgen in the build script to keep the C header aligned with the Rust FFI definitions. Store the patient handle as a void pointer to avoid layout mismatches and refresh the generated header and repository guidelines.
2.5 KiB
2.5 KiB
Repository Guidelines
Project Structure & Module Organization
src/contains the crate root (src/lib.rs) and organ modules undersrc/organs/.- Shared data types live in
src/types.rs; domain errors insrc/error.rs. - FFI layer is
src/ffi.rswith matching C header inffi/medicallib.h; keep them aligned. - Integration tests sit in
tests/(runcargo test --test patientto target a file). - Usage and tracing demos live in
examples/; the C example is inexamples/c/. - Performance benchmarks use Criterion in
benches/(seebenches/heart.rs). - Architectural and setup docs are at the repo root (
README.md,ARCHITECTURE.md,INSTALL.md,MIGRATION.md).
Build, Test, and Development Commands
cargo buildcompiles the library in debug mode for fast iteration.cargo build --release --features ffiproduces the shared library for FFI consumers.cargo testruns the full test suite; append--test <name>for a single integration test.cargo run --example usageorcargo run --example tracing_demoexercises examples.cargo benchexecutes Criterion benchmarks; compare results across runs intarget/criterion/.cargo clippy --all-targets -- -D warningsenforces lint hygiene before committing.
Coding Style & Naming Conventions
- Use
cargo fmt --all(4-space indent, ~100-char lines) before sending patches. - Modules and files use
snake_case; types and traits useCamelCase; constants areSCREAMING_SNAKE_CASE. - Favor standard library and existing crates; document any
unsafewith clear safety notes. - Keep public APIs cohesive within
src/organs/; update examples/docs when the FFI surface changes.
Testing Guidelines
- Prefer integration coverage in
tests/; create files named after features (e.g.,tests/ffi.rs). - Add focused unit tests near code under
#[cfg(test)]for invariants. - Ensure tests are deterministic; avoid sleeps or external I/O without guards.
- Run
cargo testandcargo clippylocally before opening a PR.
Commit & Pull Request Guidelines
- Write imperative commit subjects (e.g., “Add heart rate update clamp”); Conventional Commits are welcome.
- PRs should link related issues, call out breaking changes, and mention new tests or examples.
- Include reproduction steps or screenshots only when they clarify user-facing changes.
Security & FFI Notes
- Any change to
src/ffi.rsmust be mirrored inffi/medicallib.hand validated againstexamples/c/ffi_example.c. - Avoid introducing new runtime dependencies; discuss first if unavoidable.