Skip to main content

hdf5_pure/
lib.rs

1//! Pure-Rust HDF5 file reading and writing library.
2//!
3//! `hdf5-pure` is a zero-C-dependency crate for creating and reading HDF5 files.
4//! It is WASM-compatible and supports `no_std` environments with `alloc`.
5//!
6//! # Writing files
7//!
8//! ```rust
9//! use hdf5_pure::{FileBuilder, AttrValue};
10//!
11//! let mut builder = FileBuilder::new();
12//! builder.create_dataset("data")
13//!     .with_f64_data(&[1.0, 2.0, 3.0])
14//!     .with_shape(&[3])
15//!     .set_attr("unit", AttrValue::String("m/s".into()));
16//! let bytes = builder.finish().unwrap();
17//! ```
18//!
19//! # Reading files
20//!
21//! ```rust,no_run
22//! use hdf5_pure::File;
23//!
24//! let file = File::from_bytes(std::fs::read("output.h5").unwrap()).unwrap();
25//! let ds = file.dataset("data").unwrap();
26//! let values = ds.read_f64().unwrap();
27//! ```
28
29#![cfg_attr(not(feature = "std"), no_std)]
30
31#[cfg(not(feature = "std"))]
32extern crate alloc;
33
34// ---------------------------------------------------------------------------
35// Format-level modules (from rustyhdf5-format)
36// ---------------------------------------------------------------------------
37
38pub mod attribute;
39pub mod attribute_info;
40pub mod chunk_cache;
41pub mod chunked_read;
42pub mod chunked_write;
43pub mod file_writer;
44pub mod metadata_index;
45pub mod object_header_writer;
46pub mod type_builders;
47pub mod btree_v1;
48pub mod checksum;
49pub mod btree_v2;
50pub mod fractal_heap;
51pub mod group_info;
52pub mod group_v2;
53pub mod link_info;
54pub mod link_message;
55pub mod data_layout;
56pub mod data_read;
57pub mod filter_pipeline;
58pub mod extensible_array;
59pub mod fixed_array;
60pub mod filters;
61#[cfg(feature = "parallel")]
62pub mod lane_partition;
63#[cfg(feature = "parallel")]
64pub mod parallel_read;
65pub mod dataspace;
66pub mod datatype;
67pub mod error;
68pub mod global_heap;
69pub mod group_v1;
70pub mod local_heap;
71pub mod message_type;
72pub mod object_header;
73pub mod shared_message;
74pub mod signature;
75pub mod superblock;
76pub mod symbol_table;
77pub mod vl_data;
78
79#[cfg(feature = "provenance")]
80pub mod provenance;
81
82#[cfg(not(feature = "std"))]
83pub(crate) mod nosync;
84
85// ---------------------------------------------------------------------------
86// High-level modules
87// ---------------------------------------------------------------------------
88
89#[cfg(feature = "std")]
90pub mod reader;
91#[cfg(feature = "std")]
92pub mod types;
93#[cfg(feature = "std")]
94pub mod writer;
95
96// ---------------------------------------------------------------------------
97// Public API re-exports
98// ---------------------------------------------------------------------------
99
100#[cfg(feature = "std")]
101pub use error::Error;
102pub use error::FormatError;
103
104#[cfg(feature = "std")]
105pub use reader::{Dataset, File, Group};
106
107#[cfg(feature = "std")]
108pub use types::{AttrValue, DType};
109
110#[cfg(feature = "std")]
111pub use writer::FileBuilder;
112
113pub use type_builders::{
114    CompoundTypeBuilder, EnumTypeBuilder,
115    make_f32_type, make_f64_type, make_i8_type, make_i16_type, make_i32_type, make_i64_type,
116    make_u8_type, make_u16_type, make_u32_type, make_u64_type,
117};