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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
//! biodream — zero-copy, streaming-capable toolkit for reading and writing
//! BIOPAC `AcqKnowledge` (.acq) files across all known format versions (v30–v84+).
//!
//! # Quick start
//!
//! ```rust,ignore
//! // Read a file in one call
//! let df = biodream::read_file("recording.acq")?.into_value();
//! println!("{}", df.summary());
//!
//! // Lazy: parse headers without loading sample data
//! let lazy = biodream::open_file("recording.acq")?;
//! println!("{} channels", lazy.channel_count());
//! let ecg = lazy.load_channel(0)?;
//!
//! // Filter to specific channels
//! let df = biodream::ReadOptions::new()
//! .channels(&[0, 2])
//! .scaled(true)
//! .read_file("recording.acq")?
//! .into_value();
//! ```
//!
//! # Feature flags
//!
//! | Feature | Default | Description |
//! |---------|---------|-------------|
//! | `std` | via `read` | Standard library support |
//! | `read` | yes | Read .acq files from disk or streams |
//! | `write` | no | Write .acq files (requires `read`) |
//! | `csv` | yes | CSV export |
//! | `arrow` | no | Apache Arrow IPC export |
//! | `parquet` | no | Parquet export (requires `arrow`) |
//! | `hdf5` | no | HDF5 export (requires libhdf5-dev) |
//! | `serde` | no | Serde derive for domain types |
//! | `physio` | no | Physiological signal processing (R-peaks, PPG feet, PTT, Sync detection) |
//!
//! # `no_std`
//!
//! The core library (`domain` + `error` modules) is `no_std` compatible with
//! `alloc`. I/O adapters and export targets require the `std` feature (enabled
//! transitively by `read`).
extern crate alloc;
// Bring std into scope for features that require it.
extern crate std;
/// Binary parser for .acq files. Requires the `read` feature for I/O.
/// High-level ergonomic API: `ReadOptions` and `LazyDatafile`.
/// Physiological signal processing: R-peak detection, PPG foot detection, PTT.
// Top-level re-exports for the most commonly used types.
pub use ;
pub use ;
// Re-export the ergonomic API types at crate root.
pub use ;
// ---------------------------------------------------------------------------
// Top-level convenience functions
// ---------------------------------------------------------------------------
/// Read a `.acq` file from the filesystem.
///
/// Both compressed and uncompressed files are handled transparently.
/// Returns a [`ParseResult`] containing the [`Datafile`] and any non-fatal
/// [`Warning`]s.
///
/// For more control over which channels are loaded or whether samples are
/// scaled, use [`ReadOptions`].
/// Parse a `.acq` file from an in-memory byte slice.
///
/// Useful for WASM and embedded contexts where filesystem access is
/// unavailable.
/// Read a `.acq` file from any [`std::io::Read`] + [`std::io::Seek`] source.
/// Open a `.acq` file for lazy channel access.
///
/// Headers and markers are parsed immediately. Channel sample data is only
/// read when first requested via [`LazyDatafile::load_channel`].
///
/// See also: [`read_file`] for loading all data at once.
// ---------------------------------------------------------------------------
// CSV export convenience re-exports
// ---------------------------------------------------------------------------
/// Export a [`Datafile`] to CSV.
///
/// See [`export::csv::to_csv`] for full documentation.
pub use to_csv;
/// Options controlling CSV output (delimiter, precision, time format, …).
pub use CsvOptions;
/// Time-column format for CSV export.
pub use TimeFormat;
// ---------------------------------------------------------------------------
// Arrow / Parquet export convenience re-exports
// ---------------------------------------------------------------------------
/// Export a [`Datafile`] as an Arrow IPC stream.
///
/// See [`export::arrow::to_arrow_ipc`] for full documentation.
pub use to_arrow_ipc;
/// Export a [`Datafile`] as a Parquet file.
///
/// See [`export::parquet::to_parquet`] for full documentation.
pub use to_parquet;
/// Options for Parquet export (compression level, …).
pub use ParquetOptions;
// ---------------------------------------------------------------------------
// HDF5 export convenience re-exports
// ---------------------------------------------------------------------------
/// Export a [`Datafile`] as an HDF5 file.
pub use to_hdf5;
/// Options for HDF5 export.
pub use Hdf5Options;
// ---------------------------------------------------------------------------
// Inspect API — parse headers only, no sample data loaded
// ---------------------------------------------------------------------------
/// Parse headers from a `.acq` file without loading sample data.
///
/// Returns an [`InspectReport`] with graph metadata, per-channel info,
/// foreign-data length, and the byte offset where sample data begins.
pub use inspect_file;
/// Parse headers from an in-memory `.acq` byte slice without loading samples.
pub use inspect_bytes;
/// Low-level diagnostic report returned by [`inspect_file`] and [`inspect_bytes`].
pub use InspectReport;
/// Per-channel header info in an [`InspectReport`].
pub use ChannelInspect;
// ---------------------------------------------------------------------------
// Write convenience re-exports
// ---------------------------------------------------------------------------
/// Write a [`Datafile`] to a `.acq` file using default options (uncompressed, Pre-4).
///
/// See [`writer::write_file`] and [`WriteOptions`] for full documentation.
pub use write_file;
/// Write a [`Datafile`] to any [`std::io::Write`] sink using default options.
pub use write_stream;
/// Options controlling how a [`Datafile`] is serialised to `.acq` format.
///
/// Use builder methods to customise compression, revision, and byte order, then
/// call [`WriteOptions::write_file`] or [`WriteOptions::write_stream`].
pub use WriteOptions;