hdf5_rust/lib.rs
1//! Pure-Rust HDF5 reader and writer. No libhdf5, no C FFI, no crate dependencies.
2//!
3//! IEEE values are integer bit patterns (`u64` / `u32`). Opaque datasets are
4//! raw records. Hardware IEEE arithmetic is not used.
5//!
6//! Atomic n-bit decompression, little-endian integer scale-offset, Fletcher32,
7//! and `Huff::decode` are derived from HDF5 and from `puff.c`. The copyright
8//! and permission notices for those portions are in the crate `NOTICE`.
9
10#![cfg_attr(not(feature = "std"), no_std)]
11#![deny(missing_docs)]
12#![deny(clippy::float_arithmetic)]
13#![deny(clippy::suspicious)]
14
15extern crate alloc;
16
17mod btree;
18mod btree2;
19mod buf;
20mod checksum;
21mod chunk_index;
22mod consts;
23mod decode;
24mod earray;
25mod encode;
26mod error;
27mod file;
28mod filter;
29mod inflate;
30mod messages;
31mod model;
32mod ohdr;
33mod superblock;
34
35pub use consts::*;
36pub use error::{HDF5Error, Result};
37pub use file::{dataset_dtype, dataset_shape, list_datasets, list_groups, Hdf5File};
38pub use messages::{CompoundField, CompoundMemberKind};
39
40/// Dataset datatype as reported by [`Hdf5File::dataset_dtype`].
41#[derive(Clone, Copy, Debug, PartialEq, Eq)]
42pub enum HDF5DType {
43 /// IEEE 754 binary64, little-endian.
44 Float64,
45 /// IEEE 754 binary32, little-endian.
46 Float32,
47 /// Signed 8-bit integer, little-endian.
48 Int8,
49 /// Signed 16-bit integer, little-endian.
50 Int16,
51 /// Signed 32-bit integer, little-endian.
52 Int32,
53 /// Signed 64-bit integer, little-endian.
54 Int64,
55 /// Unsigned 8-bit integer, little-endian.
56 UInt8,
57 /// Unsigned 16-bit integer, little-endian.
58 UInt16,
59 /// Unsigned 32-bit integer, little-endian.
60 UInt32,
61 /// Unsigned 64-bit integer, little-endian.
62 UInt64,
63 /// Opaque element of `size` bytes.
64 Opaque(usize),
65 /// Compound / structured element of `size` bytes. Field layout via
66 /// [`Hdf5File::compound_fields`].
67 Compound {
68 /// Element size in bytes.
69 size: usize,
70 },
71 /// Any other HDF5 datatype this crate does not specialize.
72 Other,
73}
74
75/// Well-formed file whose dataset `data` is chunked (error-gold fixture).
76#[doc(hidden)]
77pub fn fixture_chunked_dataset() -> Result<alloc::vec::Vec<u8>> {
78 encode::encode_chunked_stub()
79}