Skip to main content

Crate rustyhdf5_format

Crate rustyhdf5_format 

Source
Expand description

Pure-Rust HDF5 binary format parsing and writing.

rustyhdf5-format is a zero-dependency (no C libhdf5) crate for reading and writing HDF5 files. It supports no_std environments with the alloc crate.

§Writing files

Use file_writer::FileWriter to create HDF5 files:

use rustyhdf5_format::file_writer::{FileWriter, AttrValue};

let mut fw = FileWriter::new();
fw.create_dataset("data")
    .with_f64_data(&[1.0, 2.0, 3.0])
    .with_shape(&[3])
    .set_attr("unit", AttrValue::String("m/s".into()));
let bytes = fw.finish().unwrap();

§Reading files

Parsing follows the HDF5 object model: superblock → object header → messages.

use rustyhdf5_format::{signature, superblock, object_header, group_v2,
    datatype, dataspace, data_layout, data_read, message_type::MessageType};

let file_data = std::fs::read("output.h5").unwrap();
let sig = signature::find_signature(&file_data).unwrap();
let sb  = superblock::Superblock::parse(&file_data, sig).unwrap();
let addr = group_v2::resolve_path_any(&file_data, &sb, "data").unwrap();
let hdr = object_header::ObjectHeader::parse(
    &file_data, addr as usize, sb.offset_size, sb.length_size).unwrap();

§Features

FeatureDefaultDescription
stdyesStandard library support
checksumyesJenkins lookup3 checksum validation
deflateyesDeflate (gzip) compression via flate2
provenanceyesSHINES provenance — SHA-256 hashing & verification

Modules§

attribute
HDF5 Attribute message parsing (message type 0x000C).
attribute_info
HDF5 Attribute Info message parsing (message type 0x0015).
btree_v1
HDF5 B-tree v1 parsing (type 0 for groups).
btree_v2
HDF5 B-tree v2 parsing.
checksum
HDF5 metadata checksum: Jenkins lookup3 hashlittle and CRC32.
chunk_cache
Chunk cache with hash-based index and LRU eviction.
chunked_read
Chunked dataset reading: B-tree v1 type 1 traversal and chunk assembly.
chunked_write
Chunked dataset writing: chunk splitting, compression, index building.
data_layout
HDF5 Data Layout message parsing (message type 0x0008).
data_read
Raw data reading and typed conversion for HDF5 datasets.
dataspace
HDF5 Dataspace message parsing (message type 0x0001).
datatype
HDF5 Datatype message parsing (message type 0x0003).
error
Error types for HDF5 format parsing.
extensible_array
HDF5 Extensible Array index parsing for chunked datasets (v4 index type 4).
file_writer
HDF5 file creation (write pipeline).
filter_pipeline
HDF5 Filter Pipeline message parsing (message type 0x000B).
filters
HDF5 filter implementations: deflate, shuffle, fletcher32.
fixed_array
HDF5 Fixed Array index parsing for chunked datasets (v4 index type 3).
fractal_heap
HDF5 Fractal Heap parsing for v2 group link storage.
global_heap
HDF5 Global Heap collection parsing.
group_info
HDF5 Group Info message parsing (message type 0x000A).
group_v1
V1 group traversal: resolve group children and navigate paths.
group_v2
V2 group traversal: resolve group children and navigate paths.
link_info
HDF5 Link Info message parsing (message type 0x0002).
link_message
HDF5 Link message parsing (message type 0x0006).
local_heap
HDF5 Local Heap parsing.
message_type
HDF5 object header message type identifiers.
metadata_index
Index-table + metadata-block architecture for independent parallel dataset creation.
object_header
HDF5 Object Header parsing (v1 and v2).
object_header_writer
Object header writer for v2 format.
provenance
SHINES provenance: SHA-256 content hashing, provenance attributes, and data-integrity verification.
shared_message
HDF5 Shared Object Header Message resolution.
signature
HDF5 file signature (magic bytes) detection.
superblock
HDF5 Superblock parsing for versions 0, 1, 2, and 3.
symbol_table
HDF5 Symbol Table Message and Symbol Table Node (SNOD) parsing.
type_builders
Builder types for HDF5 datatypes, attributes, datasets, and groups.
vl_data
Variable-length data reading (VL strings & VL sequences).