Skip to content

Commit 5bc25e5

Browse files
committed
Fixup types and ChunkInfoRef
1 parent 41a64ed commit 5bc25e5

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

hdf5/src/hl/chunks.rs

+18-19
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ use hdf5_sys::h5d::{H5Dget_chunk_info, H5Dget_num_chunks};
88
pub struct ChunkInfo {
99
/// Array with a size equal to the dataset’s rank whose elements contain 0-based
1010
/// logical positions of the chunk’s first element in each dimension.
11-
pub offset: Vec<u64>,
11+
pub offset: Vec<hsize_t>,
1212
/// Filter mask that indicates which filters were used with the chunk when written.
1313
///
1414
/// A zero value indicates that all enabled filters are applied on the chunk.
1515
/// A filter is skipped if the bit corresponding to the filter’s position in
1616
/// the pipeline (0 ≤ position < 32) is turned on.
1717
pub filter_mask: u32,
1818
/// Chunk address in the file.
19-
pub addr: u64,
19+
pub addr: haddr_t,
2020
/// Chunk size in bytes.
21-
pub size: u64,
21+
pub size: hsize_t,
2222
}
2323

2424
#[cfg(feature = "1.10.5")]
@@ -67,28 +67,28 @@ pub(crate) fn get_num_chunks(ds: &Dataset) -> Option<usize> {
6767
}
6868

6969
#[cfg(feature = "1.14.0")]
70-
mod one_thirteen {
70+
mod v1_14_0 {
7171
use super::*;
7272
use hdf5_sys::h5d::H5Dchunk_iter;
7373

7474
/// Borrowed version of [ChunkInfo](crate::dataset::ChunkInfo)
7575
#[derive(Clone, Debug, PartialEq, Eq)]
7676
pub struct ChunkInfoRef<'a> {
77-
pub offset: &'a [u64],
77+
pub offset: &'a [hsize_t],
7878
pub filter_mask: u32,
79-
pub addr: u64,
80-
pub size: u64,
79+
pub addr: haddr_t,
80+
pub size: hsize_t,
8181
}
8282

83-
impl<'a> ChunkInfoBorrowed<'a> {
83+
impl<'a> ChunkInfoRef<'a> {
8484
/// Returns positional indices of disabled filters.
8585
pub fn disabled_filters(&self) -> Vec<usize> {
8686
(0..32).filter(|i| self.filter_mask & (1 << i) != 0).collect()
8787
}
8888
}
8989

90-
impl<'a> From<ChunkInfoBorrowed<'a>> for ChunkInfo {
91-
fn from(val: ChunkInfoBorrowed<'a>) -> Self {
90+
impl<'a> From<ChunkInfoRef<'a>> for ChunkInfo {
91+
fn from(val: ChunkInfoRef<'a>) -> Self {
9292
Self {
9393
offset: val.offset.to_owned(),
9494
filter_mask: val.filter_mask,
@@ -109,18 +109,17 @@ mod one_thirteen {
109109
op_data: *mut c_void,
110110
) -> herr_t
111111
where
112-
F: FnMut(ChunkInfoBorrowed) -> i32,
112+
F: FnMut(ChunkInfoRef) -> i32,
113113
{
114114
unsafe {
115115
std::panic::catch_unwind(|| {
116116
let data: *mut RustCallback<F> = op_data.cast::<RustCallback<F>>();
117117
let ndims = (*data).ndims;
118118
let callback = &mut (*data).callback;
119119

120-
let offset = std::slice::from_raw_parts(offset, ndims);
120+
let offset = std::slice::from_raw_parts(offset, ndims as usize);
121121

122-
let info =
123-
ChunkInfoBorrowed { offset, filter_mask, addr: addr as u64, size: size as u64 };
122+
let info = ChunkInfoRef { offset, filter_mask, addr, size };
124123

125124
callback(info)
126125
})
@@ -130,9 +129,9 @@ mod one_thirteen {
130129

131130
pub(crate) fn visit<F>(ds: &Dataset, callback: F) -> Result<()>
132131
where
133-
F: for<'a> FnMut(ChunkInfoBorrowed<'a>) -> i32,
132+
F: for<'a> FnMut(ChunkInfoRef<'a>) -> i32,
134133
{
135-
let mut data = RustCallback::<F> { ndims: ds.ndim(), callback };
134+
let mut data = RustCallback::<F> { ndims: ds.ndim() as _, callback };
136135

137136
h5try!(H5Dchunk_iter(
138137
ds.id(),
@@ -159,7 +158,7 @@ mod one_thirteen {
159158
ds.write(&ndarray::arr2(&[[1, 2], [3, 4], [5, 6]])).unwrap();
160159

161160
let mut i = 0;
162-
let f = |c: ChunkInfoBorrowed| {
161+
let f = |c: ChunkInfoRef| {
163162
match i {
164163
0 => assert_eq!(c.offset, [0, 0]),
165164
1 => assert_eq!(c.offset, [0, 1]),
@@ -179,5 +178,5 @@ mod one_thirteen {
179178
}
180179
}
181180
}
182-
#[cfg(feature = "1.13.0")]
183-
pub use one_thirteen::*;
181+
#[cfg(feature = "1.14.0")]
182+
pub use v1_14_0::*;

hdf5/src/hl/dataset.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl Dataset {
121121
#[cfg(feature = "1.13.0")]
122122
pub fn chunks_visit<F>(&self, callback: F) -> Result<()>
123123
where
124-
F: for<'a> FnMut(crate::dataset::ChunkInfoBorrowed<'a>) -> i32,
124+
F: for<'a> FnMut(crate::dataset::ChunkInfoRef<'a>) -> i32,
125125
{
126126
crate::hl::chunks::visit(self, callback)
127127
}

hdf5/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ mod export {
7979
pub mod dataset {
8080
#[cfg(feature = "1.10.5")]
8181
pub use crate::hl::chunks::ChunkInfo;
82-
#[cfg(feature = "1.13.0")]
83-
pub use crate::hl::chunks::ChunkInfoBorrowed;
82+
#[cfg(feature = "1.14.0")]
83+
pub use crate::hl::chunks::ChunkInfoRef;
8484
pub use crate::hl::dataset::{Chunk, Dataset, DatasetBuilder};
8585
pub use crate::hl::plist::dataset_access::*;
8686
pub use crate::hl::plist::dataset_create::*;

0 commit comments

Comments
 (0)