1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Organ physics substrate — cardiac pacemaker simulation.
//!
//! `organpool` simulates the cardiac conduction system: an autonomous
//! oscillator driven by ion channel cycling (HCN → Ca²⁺ → K⁺ → refractory),
//! modulated by the autonomic nervous system (NE accelerates, ACh decelerates).
//!
//! The heart runs its own thread with its own chemical environment.
//! External sources inject chemicals; the heart metabolizes them internally.
//! If nothing injects, chemicals decay to resting baselines and the heart
//! beats at its intrinsic rate. A denervated heart still beats — like a
//! transplanted human heart.
//!
//! # Architecture
//!
//! ```text
//! Brain injects ──→ [mpsc channel] ──→ Heart's chemical pool (internal)
//! │ metabolism (enzymatic decay)
//! ↓
//! SA Node → AV Node → Conduction → Myocardium → BeatEvent channel
//! ```
//!
//! - **SA node**: Master pacemaker with intrinsic HCN leak current
//! - **AV node**: Delay gate preventing atrial/ventricular overlap
//! - **Conduction**: Bundle of His + Purkinje fibers
//! - **Myocardium**: Contractile mass — its firing IS the heartbeat
//!
//! # Usage
//!
//! ```no_run
//! use organpool::CardiacPipeline;
//! use std::time::Duration;
//!
//! // Start the heart — it begins beating immediately at intrinsic rate
//! let heart = CardiacPipeline::start();
//!
//! // Inject NE (sympathetic burst — decays over ~2.5s half-life)
//! heart.inject_ne(200);
//!
//! // Observe beats
//! while let Ok(beat) = heart.beats.recv_timeout(Duration::from_secs(2)) {
//! println!("Beat #{} IBI={}μs", beat.beat_number, beat.ibi_us);
//! }
//!
//! // Stop the heart
//! let snapshot = heart.stop();
//! println!("Final BPM: {}", snapshot.last_bpm);
//! ```
// Re-export primary types at crate root
pub use ;
pub use ;
pub use ;
pub use AutonomicBridge;