Skip to content

Commit 43351b9

Browse files
refactor: Move References to Module in H5Types
1 parent 88e2ff1 commit 43351b9

3 files changed

Lines changed: 25 additions & 22 deletions

File tree

hdf5-types/src/h5type.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::os::raw::c_void;
44
use std::ptr;
55

66
use crate::array::VarLenArray;
7+
use crate::references::Reference;
78
use crate::string::{FixedAscii, FixedUnicode, VarLenAscii, VarLenUnicode};
89

910
#[allow(non_camel_case_types)]
@@ -381,25 +382,6 @@ unsafe impl H5Type for VarLenUnicode {
381382
}
382383
}
383384

384-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
385-
pub enum Reference {
386-
Object,
387-
Region,
388-
#[cfg(feature = "1.12.0")]
389-
Std,
390-
}
391-
392-
impl Reference {
393-
fn size(self) -> usize {
394-
match self {
395-
Self::Object => mem::size_of::<hdf5_sys::h5r::hobj_ref_t>(),
396-
Self::Region => mem::size_of::<hdf5_sys::h5r::hdset_reg_ref_t>(),
397-
#[cfg(feature = "1.12.0")]
398-
Self::Std => mem::size_of::<hdf5_sys::h5r::H5R_ref_t>(),
399-
}
400-
}
401-
}
402-
403385
#[cfg(test)]
404386
pub mod tests {
405387
use super::TypeDescriptor as TD;

hdf5-types/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ mod complex;
2929
pub use self::array::VarLenArray;
3030
pub use self::dyn_value::{DynValue, OwnedDynValue};
3131
pub use self::h5type::{
32-
CompoundField, CompoundType, EnumMember, EnumType, FloatSize, H5Type, IntSize, Reference,
33-
TypeDescriptor,
32+
CompoundField, CompoundType, EnumMember, EnumType, FloatSize, H5Type, IntSize, TypeDescriptor,
3433
};
34+
pub use self::references::Reference;
3535
pub use self::string::{FixedAscii, FixedUnicode, StringError, VarLenAscii, VarLenUnicode};
3636

3737
pub(crate) unsafe fn malloc(n: usize) -> *mut core::ffi::c_void {

hdf5-types/src/references.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
// TODO: move references to this location
1+
//! Types for references.
2+
3+
use std::mem;
4+
5+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6+
pub enum Reference {
7+
Object,
8+
Region,
9+
#[cfg(feature = "1.12.0")]
10+
Std,
11+
}
12+
13+
impl Reference {
14+
pub fn size(self) -> usize {
15+
match self {
16+
Self::Object => mem::size_of::<hdf5_sys::h5r::hobj_ref_t>(),
17+
Self::Region => mem::size_of::<hdf5_sys::h5r::hdset_reg_ref_t>(),
18+
#[cfg(feature = "1.12.0")]
19+
Self::Std => mem::size_of::<hdf5_sys::h5r::H5R_ref_t>(),
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)