Skip to content

hdf5-pure

Pure-Rust HDF5 — read, write, and edit files in place.

No C dependencies. No build scripts. WASM-compatible. Interoperable with the reference HDF5 C library, h5py, and MATLAB.

Get started Quick start View on GitHub

read write edit in place streaming SWMR compression compound types ndarray MATLAB v7.3 no_std WASM

crates.io docs.rs CI License: MIT

hdf5-pure is a zero-C-dependency crate for creating, reading, and editing HDF5 files. It builds on stable Rust with no C toolchain, runs in the browser via WebAssembly, and writes files that the reference HDF5 C library, h5py, and MATLAB read without conversion.

What it does

  • Write & read


    Build files with datasets, groups, attributes, and nested hierarchies — in memory or on disk. Read v0–v3 superblocks, v1/v2 object headers, and contiguous, chunked, or compact storage.

    Writing files

  • Edit in place


    Add, delete, and copy objects in an existing file without rewriting it. The cost is proportional to what changes, and a failed commit leaves the file valid.

    Editing in place

  • Compression & filters


    Deflate, shuffle, scale-offset (lossless integer / lossy float), and an optional pure-Rust ZFP codec — all built-in HDF5 filters, so the files stay portable.

    Compression & filters

  • Streaming & SWMR


    Read files too large to buffer with on-demand chunk fetching, and append to unlimited datasets while other processes read them concurrently.

    Streaming · SWMR

  • MATLAB v7.3


    Read and write .mat v7.3 files: userblocks, the MATLAB struct convention, and a serde path that maps Rust structs straight to MATLAB variables.

    MATLAB v7.3

  • WASM & no_std


    Pure Rust, no C toolchain. The in-memory API runs in the browser via WebAssembly; turn default features off to compile for bare-metal no_std.

    Portability

A first taste

use hdf5_pure::{AttrValue, FileBuilder};

let mut builder = FileBuilder::new();
builder
    .create_dataset("temperature")
    .with_f64_data(&[22.5, 23.1, 21.8])
    .set_attr("unit", AttrValue::AsciiString("degC".into()));
builder.set_attr("version", AttrValue::I64(2));

// In memory (WASM-friendly) — or `builder.write("out.h5")` for a file.
let bytes: Vec<u8> = builder.finish().unwrap();
use hdf5_pure::File;

let file = File::from_bytes(bytes).unwrap();
let ds = file.dataset("temperature").unwrap();

assert_eq!(ds.shape().unwrap(), vec![3]);
assert_eq!(ds.read_f64().unwrap(), vec![22.5, 23.1, 21.8]);

let version = file.root().attrs().unwrap().get("version").cloned();
assert_eq!(version, Some(hdf5_pure::AttrValue::I64(2)));

Ready to dig in? Start with Installation and the Quick Start, then browse the Guide. Every page mirrors a runnable example under examples/.