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
//! Minimal utilities for reading and writing ASAM MDF 4 files.
//!
//! The crate exposes a high level API under [`api`] to inspect existing
//! recordings as well as a [`writer::MdfWriter`] to generate new files. Only a
//! fraction of the MDF 4 specification is implemented.
/// File-cutting utilities (native only; not available on `wasm32-unknown-unknown`).
/// File-merging utilities (native only; not available on `wasm32-unknown-unknown`).
// ---------------------------------------------------------------------------
// The cross-language API contract, re-exported at the crate root.
// Keep this list in step with `docs/api-contract.json` (checked by
// `tests/api_contract.rs`).
// ---------------------------------------------------------------------------
pub use Mdf;
pub use FileLayout;
pub use DataType;
pub use to_column_oriented;
pub use ;
pub use ;
pub use MdfError;
pub use ;
pub use merge_files;
pub use DecodedValue;
pub use Signal;
pub use ;
pub use ;
// Python bindings module
// WebAssembly (wasm-bindgen) bindings module
// Re-export the Python module when building as an extension
use *;
/// Python bindings for the ``mf4-rs`` crate: a reader/writer for ASAM MDF 4
/// measurement files.
///
/// The API is the same in Rust, Python and TypeScript (see ``docs/API.md``).
/// Everything is addressed by **name** — channel-group and channel names.
///
/// Read — ``read`` returns a :class:`Signal` (values + timestamps), ``values``
/// a plain numpy ``float64`` array::
///
/// import mf4_rs
/// mdf = mf4_rs.Mdf.from_file("recording.mf4")
/// for g in mdf.groups:
/// print(g.name, g.record_count, g.channel_names)
/// speed = mdf.read("Speed") # Signal
/// speed.to_series() # pandas Series, datetime index
/// rpm = mdf.values("RPM", group="Engine") # numpy.ndarray[float64]
/// part = mdf.read("Speed", start_time=1.0, end_time=2.5)
///
/// Read lazily / remotely — :class:`MdfIndex` has the same reading API, but
/// fetches only the bytes a call needs from its ``source`` (file or URL)::
///
/// idx = mf4_rs.MdfIndex.from_url("https://host/recording.mf4") # metadata only
/// speed = idx.read("Speed") # range requests happen now
/// idx.save("recording.idx.json")
/// idx = mf4_rs.MdfIndex.load("recording.idx.json")
/// idx.set_source("recording.mf4") # re-attach a source after load
///
/// Write::
///
/// w = mf4_rs.MdfWriter("out.mf4")
/// w.init_mdf_file()
/// g = w.add_channel_group("Engine")
/// t = w.add_time_channel(g, "Time")
/// y = w.add_float_channel(g, "Speed")
/// w.start_data_block(g)
/// w.write_record(g, [0.0, 123.4])
/// w.finish_data_block(g)
/// w.finalize()
///
/// File tools: :func:`to_column_oriented` (cloud-friendly MDF 4.20 layout),
/// :func:`cut_mdf_by_time`, :func:`cut_mdf_by_utc`, :func:`merge_files` and
/// the :class:`FileLayout` block inspector.
///
/// Every error is an :class:`MdfException`; a missing channel raises its
/// subclass :class:`ChannelNotFoundError`.