Skip to content

Commit

Permalink
Merge pull request #261 from soph-dec/fix-definition-of-h5l_info2_t
Browse files Browse the repository at this point in the history
Fix definition of `H5L_info2_t`
  • Loading branch information
mulimoen authored Nov 8, 2023
2 parents 26046fb + cde72f3 commit 2e44e90
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions hdf5-sys/src/h5l.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -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")]
Expand All @@ -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")]
Expand All @@ -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,
Expand Down

0 comments on commit 2e44e90

Please sign in to comment.