Skip to content

Commit 2e44e90

Browse files
authored
Merge pull request #261 from soph-dec/fix-definition-of-h5l_info2_t
Fix definition of `H5L_info2_t`
2 parents 26046fb + cde72f3 commit 2e44e90

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

hdf5-sys/src/h5l.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//! Creating and manipulating links within an HDF5 group
2+
#[cfg(feature = "1.12.0")]
3+
use std::fmt;
24
use std::mem;
35

46
pub use self::H5L_type_t::*;
@@ -64,14 +66,14 @@ impl H5L_info1_t__u {
6466
}
6567

6668
#[repr(C)]
67-
#[derive(Debug, Copy, Clone)]
69+
#[derive(Copy, Clone)]
6870
#[cfg(feature = "1.12.0")]
6971
pub struct H5L_info2_t {
7072
pub type_: H5L_type_t,
7173
pub corder_valid: hbool_t,
7274
pub corder: int64_t,
7375
pub cset: H5T_cset_t,
74-
pub u: H5L_info1_t__u,
76+
pub u: H5L_info2_t__u,
7577
}
7678

7779
#[cfg(feature = "1.12.0")]
@@ -81,6 +83,29 @@ impl Default for H5L_info2_t {
8183
}
8284
}
8385

86+
#[cfg(feature = "1.12.0")]
87+
impl fmt::Debug for H5L_info2_t {
88+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
89+
let mut debug_struct = f.debug_struct("H5L_info2_t");
90+
debug_struct
91+
.field("type_", &self.type_)
92+
.field("corder_valid", &self.corder_valid)
93+
.field("corder", &self.corder)
94+
.field("cset", &self.cset);
95+
96+
match self.type_ {
97+
H5L_TYPE_HARD => {
98+
debug_struct.field("token", unsafe { &self.u.token });
99+
}
100+
H5L_TYPE_SOFT | H5L_TYPE_EXTERNAL | H5L_TYPE_MAX => {
101+
debug_struct.field("val_size", unsafe { &self.u.val_size });
102+
}
103+
H5L_TYPE_ERROR => {}
104+
}
105+
debug_struct.finish()
106+
}
107+
}
108+
84109
#[repr(C)]
85110
#[derive(Copy, Clone)]
86111
#[cfg(feature = "1.12.0")]
@@ -96,6 +121,16 @@ impl Default for H5L_info2_t__u {
96121
}
97122
}
98123

124+
#[cfg(feature = "1.12.0")]
125+
impl H5L_info2_t__u {
126+
pub unsafe fn token(&mut self) -> *mut H5O_token_t {
127+
&mut self.token as *mut H5O_token_t
128+
}
129+
pub unsafe fn val_size(&mut self) -> *mut size_t {
130+
&mut self.val_size as *mut size_t
131+
}
132+
}
133+
99134
pub type H5L_create_func_t = Option<
100135
extern "C" fn(
101136
link_name: *const c_char,

0 commit comments

Comments
 (0)