Skip to content

Commit 76172a5

Browse files
committed
Add convenience methods on ChunkInfoBorrowed
1 parent a4e1605 commit 76172a5

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

hdf5/src/hl/chunks.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,34 @@ pub(crate) fn get_num_chunks(ds: &Dataset) -> Option<usize> {
6969
mod one_thirteen {
7070
use super::*;
7171
use hdf5_sys::h5d::H5Dchunk_iter;
72+
7273
/// Borrowed version of [ChunkInfo](crate::dataset::ChunkInfo)
73-
#[derive(Debug)]
74+
#[derive(Clone, Debug, PartialEq, Eq)]
7475
pub struct ChunkInfoBorrowed<'a> {
7576
pub offset: &'a [u64],
7677
pub filter_mask: u32,
7778
pub addr: u64,
7879
pub size: u64,
7980
}
8081

82+
impl<'a> ChunkInfoBorrowed<'a> {
83+
/// Returns positional indices of disabled filters.
84+
pub fn disabled_filters(&self) -> Vec<usize> {
85+
(0..32).filter(|i| self.filter_mask & (1 << i) != 0).collect()
86+
}
87+
}
88+
89+
impl<'a> From<ChunkInfoBorrowed<'a>> for ChunkInfo {
90+
fn from(val: ChunkInfoBorrowed<'a>) -> Self {
91+
Self {
92+
offset: val.offset.to_owned(),
93+
filter_mask: val.filter_mask,
94+
addr: val.addr,
95+
size: val.size,
96+
}
97+
}
98+
}
99+
81100
struct RustCallback<F> {
82101
ndims: usize,
83102
callback: F,

0 commit comments

Comments
 (0)