Skip to content

Add attr_creation_order and attr_phase_change to GroupCreate - #236

Open
CramBL wants to merge 6 commits into
metno:mainfrom
CramBL:group-attr-creation-order
Open

Add attr_creation_order and attr_phase_change to GroupCreate #236
CramBL wants to merge 6 commits into
metno:mainfrom
CramBL:group-attr-creation-order

Conversation

@CramBL

@CramBL CramBL commented Sep 7, 2026

Copy link
Copy Markdown

Builds on top of #235

Resolves #229

Both enums were private to hl::group, so iter_visit could only be
called with Default::default() for the order arguments. The previously
private TraversalOrder is renamed to IndexType with variants Name and
CreationOrder, matching H5_index_t.
index_type now comes before iteration_order, as in H5Literate2. Until
IndexType and IterationOrder were exported the order arguments could
only be passed as Default::default(), so the reorder breaks no caller.

The closure takes the link name and LinkInfo and returns Result<()>.
Its error is returned from iter_visit instead of being reported as a
stop with a partial result. The group argument is dropped since
H5Literate always passes back the group being iterated, and the
accumulator argument is dropped since the closure can capture its own
state.

find_link takes a closure returning Result<Option<B>> and stops at the
first Some, returning the value. Together with the error this maps onto
the continue, stop and fail returns of the C callback.

iter_visit_from takes a LinkCursor and returns the cursor of the next
link together with the value, so a stopped iteration can be resumed.
The cursor carries the index type and iteration order it counts along,
so it cannot be reused with a different traversal. A cursor at or past
the last link yields None instead of the HDF5 out of bounds error.

A panic in the closure is resumed after H5Literate returns instead of
being reported as an HDF5 error.
The bitflags allowed INDEXED without TRACKED, a combination HDF5 rejects
when the property list is built, so the invalid state was only caught at
runtime. The enum with Untracked, Tracked and Indexed cannot express it,
and matches LinkCreationOrder.
FileCreate and DatasetCreate already expose both. A group tracking
attribute creation order is what h5py's track_order=True and netCDF-4
produce, and it is required for iterating attributes by creation order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for H5Pset_attr_creation_order and H5Pset_attr_phase_change on GroupCreateBuilder

1 participant