mdf4-rs
⚠️ Work in Progress: This project is under active development and not yet ready for production use.
A safe, efficient Rust library for reading and writing ASAM MDF 4 (Measurement Data Format) files.
Features
- 100% safe Rust -
#![forbid(unsafe_code)] - Minimal dependencies - Only
serde/serde_jsonfor serialization - Memory efficient - Streaming index for large files (335x faster, 50x less memory)
- Full read/write - Create, read, and modify MDF4 files
- CAN logging - Integrated CAN bus data logging with DBC support
Quick Start
[]
= "0.1"
Reading
use MDF;
let mdf = MDFfrom_file?;
for group in mdf.channel_groups
Writing
use ;
let mut writer = new?;
writer.init_mdf_file?;
let cg = writer.add_channel_group?;
writer.add_channel?;
// ... write data
CAN Logging
use CanDbcLogger;
let dbc = parse?;
let mut logger = builder.build?;
logger.log;
let mdf_bytes = logger.finalize?;
Feature Flags
| Feature | Description | Default |
|---|---|---|
std |
Standard library with serde/serde_json | Yes |
alloc |
Heap allocation | Via std |
can |
CAN bus support via embedded-can |
Yes |
dbc |
DBC decoding via dbc-rs |
Yes |
serde |
Serialization support | Via std |
Minimal Configuration
[]
= { = "0.1", = false, = ["alloc"] }
Performance
| File Size | Streaming Index | Memory Savings |
|---|---|---|
| 1 MB | 6x faster | 50x less |
| 40 MB | 335x faster | 50x less |
Examples
See examples/ for complete working examples:
can_logging.rs- CAN bus logging workflows (decoded, raw, overlay, streaming)read_file.rs- Reading MDF4 fileswrite_file.rs- Creating MDF4 filesindex_operations.rs- Efficient file indexingmerge_files.rs- Merging multiple MDF4 filescut_file.rs- Extracting time segments
Documentation
- API Reference
- ARCHITECTURE.md - Internal design
License
MIT OR Apache-2.0. See LICENSING.md.