Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
## hdf5-sys unreleased
## hdf5-src unreleased

## hdf5-sys unreleased
- Use edition 2024

## hdf5 unreleased
- MSRV has been increased to 1.85
- Use edition 2024

## hdf5 v0.12.3
Release date: Feb 10, 2026
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
resolver = "2"
resolver = "3"
members = ["hdf5", "hdf5-types", "hdf5-derive", "hdf5-sys", "hdf5-src"]
default-members = ["hdf5", "hdf5-types", "hdf5-derive", "hdf5-sys"]

Expand All @@ -13,7 +13,7 @@ keywords = ["hdf5"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/metno/hdf5-rust"
homepage = "https://github.com/metno/hdf5-rust"
edition = "2021"
edition = "2024"

[workspace.dependencies]
# external
Expand Down
19 changes: 10 additions & 9 deletions hdf5-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::iter;
use std::mem;
use std::str::FromStr;

use proc_macro2::{Ident, Span, TokenStream};
use proc_macro_error2::{abort, proc_macro_error};
use quote::{quote, ToTokens};
use proc_macro2::{Ident, Span, TokenStream};
use quote::{ToTokens, quote};
use syn::{
parse_macro_input, AttrStyle, Attribute, Data, DeriveInput, Expr, Fields, Index, LitStr, Type,
TypeGenerics, TypePath,
AttrStyle, Attribute, Data, DeriveInput, Expr, Fields, Index, LitStr, Type, TypeGenerics,
TypePath, parse_macro_input,
};

/// Derive macro generating an impl of the trait `H5Type`.
Expand Down Expand Up @@ -190,11 +190,12 @@ fn impl_trait(
abort!(ty, "cannot derive `H5Type` for empty structs");
}

let repr =
find_repr(attrs, &["C", "packed", "transparent"]).unwrap_or_else(|| {
abort!(ty,
"`H5Type` requires repr(C), repr(packed) or repr(transparent) for structs")
});
let repr = find_repr(attrs, &["C", "packed", "transparent"]).unwrap_or_else(|| {
abort!(
ty,
"`H5Type` requires repr(C), repr(packed) or repr(transparent) for structs"
)
});
if repr == "transparent" {
assert_eq!(fields.len(), 1);
impl_transparent(&fields[0].ty)
Expand Down
11 changes: 7 additions & 4 deletions hdf5-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub struct LibrarySearcher {

#[cfg(any(all(unix, not(target_os = "macos")), windows))]
mod pkgconf {
use super::{is_inc_dir, LibrarySearcher};
use super::{LibrarySearcher, is_inc_dir};

pub fn find_hdf5_via_pkg_config(config: &mut LibrarySearcher) {
if config.inc_dir.is_some() {
Expand All @@ -263,7 +263,10 @@ mod pkgconf {
// If we're going to windows-gnu we can use pkg-config, but only so long as
// we're coming from a windows host.
if cfg!(windows) {
std::env::set_var("PKG_CONFIG_ALLOW_CROSS", "1");
// Safety: build.rs is run single-threaded
unsafe {
std::env::set_var("PKG_CONFIG_ALLOW_CROSS", "1");
}
}

// Try pkg-config. Note that HDF5 only ships pkg-config metadata
Expand Down Expand Up @@ -304,7 +307,7 @@ mod pkgconf {
#[cfg(all(unix, not(target_os = "macos")))]
mod unix {
pub use super::pkgconf::find_hdf5_via_pkg_config;
use super::{is_inc_dir, LibrarySearcher};
use super::{LibrarySearcher, is_inc_dir};

pub fn find_hdf5_in_default_location(config: &mut LibrarySearcher) {
if config.inc_dir.is_some() {
Expand Down Expand Up @@ -422,8 +425,8 @@ mod windows {
use serde::de::Error;
use serde::{Deserialize, Deserializer};
use serde_derive::Deserialize as DeriveDeserialize;
use winreg::enums::HKEY_LOCAL_MACHINE;
use winreg::RegKey;
use winreg::enums::HKEY_LOCAL_MACHINE;

impl<'de> Deserialize<'de> for Version {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
Expand Down
42 changes: 21 additions & 21 deletions hdf5-sys/src/h5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,35 @@ impl Default for H5_ih_info_t {
}
}

extern "C" {
pub fn H5open() -> herr_t;
pub fn H5close() -> herr_t;
pub fn H5dont_atexit() -> herr_t;
pub fn H5garbage_collect() -> herr_t;
pub fn H5set_free_list_limits(
unsafe extern "C" {
pub unsafe fn H5open() -> herr_t;
pub unsafe fn H5close() -> herr_t;
pub unsafe fn H5dont_atexit() -> herr_t;
pub unsafe fn H5garbage_collect() -> herr_t;
pub unsafe fn H5set_free_list_limits(
reg_global_lim: c_int, reg_list_lim: c_int, arr_global_lim: c_int, arr_list_lim: c_int,
blk_global_lim: c_int, blk_list_lim: c_int,
) -> herr_t;
pub fn H5get_libversion(
pub unsafe fn H5get_libversion(
majnum: *mut c_uint, minnum: *mut c_uint, relnum: *mut c_uint,
) -> herr_t;
pub fn H5check_version(majnum: c_uint, minnum: c_uint, relnum: c_uint) -> herr_t;
pub unsafe fn H5check_version(majnum: c_uint, minnum: c_uint, relnum: c_uint) -> herr_t;
}

#[cfg(feature = "1.8.13")]
extern "C" {
pub fn H5free_memory(mem: *mut c_void) -> herr_t;
unsafe extern "C" {
pub unsafe fn H5free_memory(mem: *mut c_void) -> herr_t;
}

#[cfg(feature = "1.8.15")]
extern "C" {
pub fn H5allocate_memory(size: size_t, clear: hbool_t) -> *mut c_void;
pub fn H5resize_memory(mem: *mut c_void, size: size_t) -> *mut c_void;
unsafe extern "C" {
pub unsafe fn H5allocate_memory(size: size_t, clear: hbool_t) -> *mut c_void;
pub unsafe fn H5resize_memory(mem: *mut c_void, size: size_t) -> *mut c_void;
}

#[cfg(feature = "1.8.16")]
extern "C" {
pub fn H5is_library_threadsafe(is_ts: *mut hbool_t) -> herr_t;
unsafe extern "C" {
pub unsafe fn H5is_library_threadsafe(is_ts: *mut hbool_t) -> herr_t;
}

#[cfg(any(all(feature = "1.10.7", not(feature = "1.12.0")), feature = "1.12.1"))]
Expand All @@ -109,9 +109,9 @@ pub struct H5_alloc_stats_t {
}

#[cfg(any(all(feature = "1.10.7", not(feature = "1.12.0")), feature = "1.12.1"))]
extern "C" {
pub fn H5get_alloc_stats(stats: *mut H5_alloc_stats_t) -> herr_t;
pub fn H5get_free_list_sizes(
unsafe extern "C" {
pub unsafe fn H5get_alloc_stats(stats: *mut H5_alloc_stats_t) -> herr_t;
pub unsafe fn H5get_free_list_sizes(
reg_size: *mut size_t, arr_size: *mut size_t, blk_size: *mut size_t, fac_size: *mut size_t,
) -> herr_t;
}
Expand All @@ -120,7 +120,7 @@ extern "C" {
type H5_atclose_func_t = Option<unsafe extern "C" fn(ctx: *mut c_void)>;

#[cfg(feature = "1.14.0")]
extern "C" {
pub fn H5atclose(func: H5_atclose_func_t, ctx: *mut c_void) -> herr_t;
pub fn H5is_library_terminating(is_terminating: *mut hbool_t) -> herr_t;
unsafe extern "C" {
pub unsafe fn H5atclose(func: H5_atclose_func_t, ctx: *mut c_void) -> herr_t;
pub unsafe fn H5is_library_terminating(is_terminating: *mut hbool_t) -> herr_t;
}
92 changes: 47 additions & 45 deletions hdf5-sys/src/h5a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,140 +42,142 @@ pub type H5A_operator2_t = Option<
) -> herr_t,
>;

extern "C" {
pub fn H5Acreate2(
unsafe extern "C" {
pub unsafe fn H5Acreate2(
loc_id: hid_t, attr_name: *const c_char, type_id: hid_t, space_id: hid_t, acpl_id: hid_t,
aapl_id: hid_t,
) -> hid_t;
pub fn H5Acreate_by_name(
pub unsafe fn H5Acreate_by_name(
loc_id: hid_t, obj_name: *const c_char, attr_name: *const c_char, type_id: hid_t,
space_id: hid_t, acpl_id: hid_t, aapl_id: hid_t, lapl_id: hid_t,
) -> hid_t;
pub fn H5Aopen(obj_id: hid_t, attr_name: *const c_char, aapl_id: hid_t) -> hid_t;
pub fn H5Aopen_by_name(
pub unsafe fn H5Aopen(obj_id: hid_t, attr_name: *const c_char, aapl_id: hid_t) -> hid_t;
pub unsafe fn H5Aopen_by_name(
loc_id: hid_t, obj_name: *const c_char, attr_name: *const c_char, aapl_id: hid_t,
lapl_id: hid_t,
) -> hid_t;
pub fn H5Aopen_by_idx(
pub unsafe fn H5Aopen_by_idx(
loc_id: hid_t, obj_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
n: hsize_t, aapl_id: hid_t, lapl_id: hid_t,
) -> hid_t;
pub fn H5Awrite(attr_id: hid_t, type_id: hid_t, buf: *const c_void) -> herr_t;
pub fn H5Aread(attr_id: hid_t, type_id: hid_t, buf: *mut c_void) -> herr_t;
pub fn H5Aclose(attr_id: hid_t) -> herr_t;
pub fn H5Aget_space(attr_id: hid_t) -> hid_t;
pub fn H5Aget_type(attr_id: hid_t) -> hid_t;
pub fn H5Aget_create_plist(attr_id: hid_t) -> hid_t;
pub fn H5Aget_name(attr_id: hid_t, buf_size: size_t, buf: *mut c_char) -> ssize_t;
pub fn H5Aget_name_by_idx(
pub unsafe fn H5Awrite(attr_id: hid_t, type_id: hid_t, buf: *const c_void) -> herr_t;
pub unsafe fn H5Aread(attr_id: hid_t, type_id: hid_t, buf: *mut c_void) -> herr_t;
pub unsafe fn H5Aclose(attr_id: hid_t) -> herr_t;
pub unsafe fn H5Aget_space(attr_id: hid_t) -> hid_t;
pub unsafe fn H5Aget_type(attr_id: hid_t) -> hid_t;
pub unsafe fn H5Aget_create_plist(attr_id: hid_t) -> hid_t;
pub unsafe fn H5Aget_name(attr_id: hid_t, buf_size: size_t, buf: *mut c_char) -> ssize_t;
pub unsafe fn H5Aget_name_by_idx(
loc_id: hid_t, obj_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
n: hsize_t, name: *mut c_char, size: size_t, lapl_id: hid_t,
) -> ssize_t;
pub fn H5Aget_storage_size(attr_id: hid_t) -> hsize_t;
pub fn H5Aget_info(attr_id: hid_t, ainfo: *mut H5A_info_t) -> herr_t;
pub fn H5Aget_info_by_name(
pub unsafe fn H5Aget_storage_size(attr_id: hid_t) -> hsize_t;
pub unsafe fn H5Aget_info(attr_id: hid_t, ainfo: *mut H5A_info_t) -> herr_t;
pub unsafe fn H5Aget_info_by_name(
loc_id: hid_t, obj_name: *const c_char, attr_name: *const c_char, ainfo: *mut H5A_info_t,
lapl_id: hid_t,
) -> herr_t;
pub fn H5Aget_info_by_idx(
pub unsafe fn H5Aget_info_by_idx(
loc_id: hid_t, obj_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
n: hsize_t, ainfo: *mut H5A_info_t, lapl_id: hid_t,
) -> herr_t;
pub fn H5Arename(loc_id: hid_t, old_name: *const c_char, new_name: *const c_char) -> herr_t;
pub fn H5Arename_by_name(
pub unsafe fn H5Arename(
loc_id: hid_t, old_name: *const c_char, new_name: *const c_char,
) -> herr_t;
pub unsafe fn H5Arename_by_name(
loc_id: hid_t, obj_name: *const c_char, old_attr_name: *const c_char,
new_attr_name: *const c_char, lapl_id: hid_t,
) -> herr_t;
pub fn H5Aiterate2(
pub unsafe fn H5Aiterate2(
loc_id: hid_t, idx_type: H5_index_t, order: H5_iter_order_t, idx: *mut hsize_t,
op: H5A_operator2_t, op_data: *mut c_void,
) -> herr_t;
pub fn H5Aiterate_by_name(
pub unsafe fn H5Aiterate_by_name(
loc_id: hid_t, obj_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
idx: *mut hsize_t, op: H5A_operator2_t, op_data: *mut c_void, lapd_id: hid_t,
) -> herr_t;
pub fn H5Adelete(loc_id: hid_t, name: *const c_char) -> herr_t;
pub fn H5Adelete_by_name(
pub unsafe fn H5Adelete(loc_id: hid_t, name: *const c_char) -> herr_t;
pub unsafe fn H5Adelete_by_name(
loc_id: hid_t, obj_name: *const c_char, attr_name: *const c_char, lapl_id: hid_t,
) -> herr_t;
pub fn H5Adelete_by_idx(
pub unsafe fn H5Adelete_by_idx(
loc_id: hid_t, obj_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
n: hsize_t, lapl_id: hid_t,
) -> herr_t;
pub fn H5Aexists(obj_id: hid_t, attr_name: *const c_char) -> htri_t;
pub fn H5Aexists_by_name(
pub unsafe fn H5Aexists(obj_id: hid_t, attr_name: *const c_char) -> htri_t;
pub unsafe fn H5Aexists_by_name(
obj_id: hid_t, obj_name: *const c_char, attr_name: *const c_char, lapl_id: hid_t,
) -> htri_t;

#[deprecated(note = "deprecated in HDF5 1.8.0, use H5Aget_info")]
pub fn H5Aget_num_attrs(loc_id: hid_t) -> c_int;
pub unsafe fn H5Aget_num_attrs(loc_id: hid_t) -> c_int;
#[deprecated(note = "deprecated in HDF5 1.8.0, use H5Aopen_by_idx")]
pub fn H5Aopen_idx(loc_id: hid_t, idx: c_uint) -> hid_t;
pub unsafe fn H5Aopen_idx(loc_id: hid_t, idx: c_uint) -> hid_t;
#[deprecated(note = "deprecated in HDF5 1.8.0, use H5Aopen_by_name")]
pub fn H5Aopen_name(loc_id: hid_t, name: *const c_char) -> hid_t;
pub unsafe fn H5Aopen_name(loc_id: hid_t, name: *const c_char) -> hid_t;
#[deprecated(note = "deprecated in HDF5 1.8.0, use H5Acreate2")]
pub fn H5Acreate1(
pub unsafe fn H5Acreate1(
loc_id: hid_t, name: *const c_char, type_id: hid_t, space_id: hid_t, acpl_id: hid_t,
) -> hid_t;
#[deprecated(note = "deprecated in HDF5 1.8.0, use H5Aiterate2")]
pub fn H5Aiterate1(
pub unsafe fn H5Aiterate1(
loc_id: hid_t, attr_num: *mut c_uint, op: H5A_operator1_t, op_data: *mut c_void,
) -> herr_t;
}

#[cfg(feature = "1.14.0")]
extern "C" {
pub fn H5Aclose_async(
unsafe extern "C" {
pub unsafe fn H5Aclose_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, attr_id: hid_t,
es_id: hid_t,
) -> herr_t;
pub fn H5Acreate_async(
pub unsafe fn H5Acreate_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, loc_id: hid_t,
attr_name: *const c_char, type_id: hid_t, space_id: hid_t, acpl_id: hid_t, aapl_id: hid_t,
es_id: hid_t,
) -> hid_t;
pub fn H5Acreate_by_name_async(
pub unsafe fn H5Acreate_by_name_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, loc_id: hid_t,
obj_name: *const c_char, attr_name: *const c_char, type_id: hid_t, space_id: hid_t,
acpl_id: hid_t, aapl_id: hid_t, lapl_id: hid_t, es_id: hid_t,
) -> hid_t;
pub fn H5Aexists_async(
pub unsafe fn H5Aexists_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, obj_id: hid_t,
attr_name: *const c_char, exists: *mut hbool_t, es_id: hid_t,
) -> herr_t;
pub fn H5Aexists_by_name_async(
pub unsafe fn H5Aexists_by_name_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, loc_id: hid_t,
obj_name: *const c_char, attr_name: *const c_char, exists: *mut hbool_t, lapl_id: hid_t,
es_id: hid_t,
) -> herr_t;
pub fn H5Aopen_async(
pub unsafe fn H5Aopen_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, obj_id: hid_t,
attr_name: *const c_char, aapl_id: hid_t, es_id: hid_t,
) -> hid_t;
pub fn H5Aopen_by_idx_async(
pub unsafe fn H5Aopen_by_idx_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, loc_id: hid_t,
obj_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t, n: c_ulong,
aapl_id: hid_t, lapl_id: hid_t, es_id: hid_t,
) -> hid_t;
pub fn H5Aopen_by_name_async(
pub unsafe fn H5Aopen_by_name_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, loc_id: hid_t,
obj_name: *const c_char, attr_name: *const c_char, aapl_id: hid_t, lapl_id: hid_t,
es_id: hid_t,
) -> hid_t;
pub fn H5Aread_async(
pub unsafe fn H5Aread_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, attr_id: hid_t,
dtype_id: hid_t, buf: *mut c_void, es_id: hid_t,
) -> herr_t;
pub fn H5Arename_async(
pub unsafe fn H5Arename_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, loc_id: hid_t,
old_name: *const c_char, new_name: *const c_char, es_id: hid_t,
) -> herr_t;
pub fn H5Arename_by_name_async(
pub unsafe fn H5Arename_by_name_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, loc_id: hid_t,
obj_name: *const c_char, old_attr_name: *const c_char, new_attr_name: *const c_char,
lapl_id: hid_t, es_id: hid_t,
) -> herr_t;
pub fn H5Awrite_async(
pub unsafe fn H5Awrite_async(
app_file: *const c_char, app_func: *const c_char, app_line: c_uint, attr_id: hid_t,
type_id: hid_t, buf: *const c_void, es_id: hid_t,
) -> herr_t;
Expand Down
Loading
Loading