diff --git a/hdf5-sys/src/h5l.rs b/hdf5-sys/src/h5l.rs index 96a9829d..a07da6be 100644 --- a/hdf5-sys/src/h5l.rs +++ b/hdf5-sys/src/h5l.rs @@ -1,4 +1,6 @@ //! Creating and manipulating links within an HDF5 group +#[cfg(feature = "1.12.0")] +use std::fmt; use std::mem; pub use self::H5L_type_t::*; @@ -64,14 +66,14 @@ impl H5L_info1_t__u { } #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Copy, Clone)] #[cfg(feature = "1.12.0")] pub struct H5L_info2_t { pub type_: H5L_type_t, pub corder_valid: hbool_t, pub corder: int64_t, pub cset: H5T_cset_t, - pub u: H5L_info1_t__u, + pub u: H5L_info2_t__u, } #[cfg(feature = "1.12.0")] @@ -81,6 +83,29 @@ impl Default for H5L_info2_t { } } +#[cfg(feature = "1.12.0")] +impl fmt::Debug for H5L_info2_t { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut debug_struct = f.debug_struct("H5L_info2_t"); + debug_struct + .field("type_", &self.type_) + .field("corder_valid", &self.corder_valid) + .field("corder", &self.corder) + .field("cset", &self.cset); + + match self.type_ { + H5L_TYPE_HARD => { + debug_struct.field("token", unsafe { &self.u.token }); + } + H5L_TYPE_SOFT | H5L_TYPE_EXTERNAL | H5L_TYPE_MAX => { + debug_struct.field("val_size", unsafe { &self.u.val_size }); + } + H5L_TYPE_ERROR => {} + } + debug_struct.finish() + } +} + #[repr(C)] #[derive(Copy, Clone)] #[cfg(feature = "1.12.0")] @@ -96,6 +121,16 @@ impl Default for H5L_info2_t__u { } } +#[cfg(feature = "1.12.0")] +impl H5L_info2_t__u { + pub unsafe fn token(&mut self) -> *mut H5O_token_t { + &mut self.token as *mut H5O_token_t + } + pub unsafe fn val_size(&mut self) -> *mut size_t { + &mut self.val_size as *mut size_t + } +} + pub type H5L_create_func_t = Option< extern "C" fn( link_name: *const c_char,