Skip to main content

rust_hdf5/format/
storage_kind.rs

1//! Storage-kind facts read off the object-header messages that split an
2//! object's metadata into an inline (compact) shape versus one moved out to
3//! a fractal heap plus a v2 B-tree index (dense) once it grows past the
4//! phase-change threshold. Attribute storage is governed by
5//! [`AttributeInfoMessage`](crate::format::messages::attr_info::AttributeInfoMessage);
6//! link storage adds a third, legacy shape (the pre-1.8 symbol table) and is
7//! governed by
8//! [`LinkInfoMessage`](crate::format::messages::link_info::LinkInfoMessage).
9
10/// Where an object's attributes physically live: inline as `Attribute`
11/// messages in the object header (`Compact`), or split into a fractal heap
12/// plus a v2 B-tree name index once the set has grown past
13/// `H5O__attr_create`'s phase-change threshold (`Dense`). Mirrors h5py's
14/// `h5py.h5o.get_info(...).meta_size.attr.index_size` check: nonzero means
15/// dense.
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
17pub enum AttributeStorage {
18    /// Attribute messages sit directly in the object header.
19    #[default]
20    Compact,
21    /// Attributes live in a fractal heap, indexed by a v2 B-tree.
22    Dense,
23}
24
25impl AttributeStorage {
26    /// Whether storage has moved out to the fractal heap.
27    pub fn is_dense(self) -> bool {
28        matches!(self, Self::Dense)
29    }
30}
31
32/// Where a group's links physically live: the pre-1.8 symbol table (a v1
33/// B-tree plus a local heap, `SymbolTable`), inline as `Link` messages in the
34/// object header (`Compact`), or split into a fractal heap plus a v2 B-tree
35/// name index once the set has grown past `H5G_obj_insert`'s phase-change
36/// threshold (`Dense`). Mirrors h5py's `link_storage_str`: a Symbol Table
37/// message wins outright, otherwise a nonzero
38/// `h5o.get_info(...).meta_size.obj.index_size` means dense.
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
40pub enum LinkStorage {
41    /// Links live in a v1 B-tree indexed local heap — the format every group
42    /// used before HDF5 1.8.
43    SymbolTable,
44    /// Link messages sit directly in the object header.
45    #[default]
46    Compact,
47    /// Links live in a fractal heap, indexed by a v2 B-tree.
48    Dense,
49}
50
51impl LinkStorage {
52    /// Whether storage has moved out to the fractal heap.
53    pub fn is_dense(self) -> bool {
54        matches!(self, Self::Dense)
55    }
56}