Skip to content

Maintenance updates #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[workspace]
resolver = "2"
members = ["hdf5", "hdf5-types", "hdf5-derive", "hdf5-sys", "hdf5-src"]
default-members = ["hdf5", "hdf5-types", "hdf5-derive", "hdf5-sys"]

[workspace.package]
version = "0.8.1" # !V
version = "0.8.1" # !V
rust-version = "1.64.0"
authors = ["Ivan Smirnov <aldanor@users.noreply.github.com>", "Magnus Ulimoen <mulimoen@users.noreply.github.com>"]
authors = [
"Ivan Smirnov <aldanor@users.noreply.github.com>",
"Magnus Ulimoen <mulimoen@users.noreply.github.com>",
]
keywords = ["hdf5"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/aldanor/hdf5-rust"
Expand All @@ -20,9 +24,9 @@ libc = "0.2"
libz-sys = { version = "1.1", default-features = false }
mpi-sys = "0.2"
num-complex = { version = "0.4", default-features = false }
regex = "1.8"
regex = "1.10"
# internal
hdf5-derive = { version = "0.8.1", path = "hdf5-derive" } # !V
hdf5-src = { version = "0.8.1", path = "hdf5-src" } # !V
hdf5-sys = { version = "0.8.1", path = "hdf5-sys" } # !V
hdf5-types = { version = "0.8.1", path = "hdf5-types" } # !V
hdf5-derive = { version = "0.8.1", path = "hdf5-derive" } # !V
hdf5-src = { version = "0.8.1", path = "hdf5-src" } # !V
hdf5-sys = { version = "0.8.1", path = "hdf5-sys" } # !V
hdf5-types = { version = "0.8.1", path = "hdf5-types" } # !V
2 changes: 1 addition & 1 deletion hdf5-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pkg-config = "0.3"
[target.'cfg(windows)'.build-dependencies]
serde = "1.0"
serde_derive = "1.0"
winreg = { version = "0.50", features = ["serialization-serde"]}
winreg = { version = "0.52", features = ["serialization-serde"] }

[package.metadata.docs.rs]
features = ["static", "zlib"]
4 changes: 2 additions & 2 deletions hdf5-sys/src/h5p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mod globals {

#[cfg(feature = "1.12.0")]
#[allow(clippy::module_inception)]
pub mod globals {
mod globals_1_12_0 {
use super::*;
extern_static!(H5P_MAP_CREATE, H5P_CLS_MAP_CREATE_ID_g);
extern_static!(H5P_MAP_ACCESS, H5P_CLS_MAP_ACCESS_ID_g);
Expand All @@ -144,7 +144,7 @@ mod globals {
extern_static!(H5P_REFERENCE_ACCESS_DEFAULT, H5P_LST_REFERENCE_ACCESS_ID_g);
}
#[cfg(feature = "1.12.0")]
pub use globals::*;
pub use globals_1_12_0::*;
}

#[cfg(all(not(feature = "1.8.14"), all(target_env = "msvc", not(feature = "static"))))]
Expand Down
1 change: 1 addition & 0 deletions hdf5-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod internal_prelude {
pub use crate::h5i::hid_t;
pub use crate::h5t::H5T_cset_t;
pub use libc::{int64_t, off_t, size_t, ssize_t, time_t, uint32_t, uint64_t, FILE};
#[allow(unused_imports)]
pub use std::os::raw::{
c_char, c_double, c_float, c_int, c_long, c_longlong, c_uchar, c_uint, c_ulong,
c_ulonglong, c_void,
Expand Down
10 changes: 5 additions & 5 deletions hdf5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ f16 = ["hdf5-types/f16"]

[dependencies]
# external
bitflags = "2.3"
blosc-sys = { version = "0.2", package = "blosc-src", optional = true }
bitflags = "2.4"
blosc-sys = { version = "0.3", package = "blosc-src", optional = true }
cfg-if = { workspace = true }
errno = { version = "0.3", optional = true }
lazy_static = "1.4"
Expand All @@ -57,11 +57,11 @@ hdf5-types = { workspace = true }
half = { workspace = true }
num-complex = { workspace = true }
paste = "1.0"
pretty_assertions = "1.3"
pretty_assertions = "1.4"
rand = { version = "0.8", features = ["small_rng"] }
regex = { workspace = true }
scopeguard = "1.1"
tempfile = "3.6"
scopeguard = "1.2"
tempfile = "3.9"

[package.metadata.docs.rs]
features = ["static", "zlib", "blosc", "lzf", "f16", "complex"]
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait ObjectClass: Sized {
let handle = Handle::try_new(id)?;
if Self::is_valid_id_type(handle.id_type()) {
let obj = Self::from_handle(handle);
obj.validate().map(|_| obj)
obj.validate().map(|()| obj)
} else {
Err(From::from(format!("Invalid {} id: {}", Self::NAME, id)))
}
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl ExpandedErrorStack {
}

pub fn top(&self) -> Option<&ErrorFrame> {
self.get(0)
self.first()
}

pub fn description(&self) -> &str {
Expand Down
4 changes: 2 additions & 2 deletions hdf5/src/hl/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<'a> Reader<'a> {
pub fn read_raw<T: H5Type>(&self) -> Result<Vec<T>> {
let size = self.obj.space()?.size();
let mut vec = Vec::with_capacity(size);
self.read_into_buf(vec.as_mut_ptr(), None, None).map(|_| {
self.read_into_buf(vec.as_mut_ptr(), None, None).map(|()| {
unsafe {
vec.set_len(size);
};
Expand Down Expand Up @@ -184,7 +184,7 @@ impl<'a> Reader<'a> {
let obj_ndim = self.obj.get_shape()?.ndim();
ensure!(obj_ndim == 0, "ndim mismatch: expected scalar, got {}", obj_ndim);
let mut val = mem::MaybeUninit::<T>::uninit();
self.read_into_buf(val.as_mut_ptr(), None, None).map(|_| unsafe { val.assume_init() })
self.read_into_buf(val.as_mut_ptr(), None, None).map(|()| unsafe { val.assume_init() })
}
}

Expand Down
6 changes: 3 additions & 3 deletions hdf5/src/hl/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl DatasetBuilderInner {
Some(dapl) => dapl.clone(),
None => DatasetAccess::try_new()?,
};
self.dapl_builder.apply(&mut dapl).map(|_| dapl)
self.dapl_builder.apply(&mut dapl).map(|()| dapl)
}

fn compute_chunk_shape(&self, dtype: &Datatype, extents: &Extents) -> Result<Option<Vec<Ix>>> {
Expand Down Expand Up @@ -468,15 +468,15 @@ impl DatasetBuilderInner {
Some(dcpl) => dcpl.clone(),
None => DatasetCreate::try_new()?,
};
dcpl_builder.apply(&mut dcpl).map(|_| dcpl)
dcpl_builder.apply(&mut dcpl).map(|()| dcpl)
}

fn build_lcpl(&self) -> Result<LinkCreate> {
let mut lcpl = match &self.lcpl_base {
Some(lcpl) => lcpl.clone(),
None => LinkCreate::try_new()?,
};
self.lcpl_builder.apply(&mut lcpl).map(|_| lcpl)
self.lcpl_builder.apply(&mut lcpl).map(|()| lcpl)
}

fn try_unlink<'n, N: Into<Option<&'n str>>>(&self, name: N) {
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/hl/extents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ impl<T: Into<SimpleExtents>> From<T> for Extents {
}

impl From<()> for Extents {
fn from(_: ()) -> Self {
fn from((): ()) -> Self {
Self::Scalar
}
}
Expand Down
8 changes: 4 additions & 4 deletions hdf5/src/hl/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ mod blosc_impl {

#[cfg(feature = "blosc")]
pub fn blosc_get_nthreads() -> u8 {
h5lock!(super::blosc::blosc_get_nthreads()).max(0).min(255) as _
h5lock!(super::blosc::blosc_get_nthreads()).clamp(0, 255) as _
}

#[cfg(feature = "blosc")]
pub fn blosc_set_nthreads(num_threads: u8) -> u8 {
use std::os::raw::c_int;
let nthreads = h5lock!(super::blosc::blosc_set_nthreads(c_int::from(num_threads)));
nthreads.max(0).min(255) as _
nthreads.clamp(0, 255) as _
}
}

Expand Down Expand Up @@ -123,11 +123,11 @@ pub struct FilterInfo {
pub(crate) fn register_filters() {
#[cfg(feature = "lzf")]
if let Err(e) = lzf::register_lzf() {
eprintln!("Error while registering LZF filter: {}", e);
eprintln!("Error while registering LZF filter: {e}");
}
#[cfg(feature = "blosc")]
if let Err(e) = blosc::register_blosc() {
eprintln!("Error while registering Blosc filter: {}", e);
eprintln!("Error while registering Blosc filter: {e}");
}
}

Expand Down
5 changes: 3 additions & 2 deletions hdf5/src/hl/filters/blosc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use hdf5_sys::h5p::{H5Pget_chunk, H5Pget_filter_by_id2, H5Pmodify_filter};
use hdf5_sys::h5t::{H5Tclose, H5Tget_class, H5Tget_size, H5Tget_super, H5T_ARRAY};
use hdf5_sys::h5z::{H5Z_class2_t, H5Z_filter_t, H5Zregister, H5Z_CLASS_T_VERS, H5Z_FLAG_REVERSE};

use crate::error::H5ErrorCode;
use crate::globals::{H5E_CALLBACK, H5E_PLIST};
use crate::internal_prelude::*;

Expand Down Expand Up @@ -50,7 +51,7 @@ lazy_static! {
}

pub fn register_blosc() -> Result<(), &'static str> {
(*BLOSC_INIT).clone()
*BLOSC_INIT
}

extern "C" fn set_local_blosc(dcpl_id: hid_t, type_id: hid_t, _space_id: hid_t) -> herr_t {
Expand Down Expand Up @@ -102,7 +103,7 @@ extern "C" fn set_local_blosc(dcpl_id: hid_t, type_id: hid_t, _space_id: hid_t)
}
values[2] = basetypesize as _;
let mut bufsize = typesize;
for &chunkdim in chunkdims[..ndims as usize].iter() {
for &chunkdim in &chunkdims[..ndims as usize] {
bufsize *= chunkdim as size_t;
}
values[3] = bufsize as _;
Expand Down
7 changes: 4 additions & 3 deletions hdf5/src/hl/filters/lzf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ use std::ptr::{self, addr_of_mut};
use std::slice;

use lazy_static::lazy_static;
use lzf_sys::{lzf_compress, lzf_decompress, LZF_VERSION};

use hdf5_sys::h5p::{H5Pget_chunk, H5Pget_filter_by_id2, H5Pmodify_filter};
use hdf5_sys::h5t::H5Tget_size;
use hdf5_sys::h5z::{H5Z_class2_t, H5Z_filter_t, H5Zregister, H5Z_CLASS_T_VERS, H5Z_FLAG_REVERSE};

use crate::error::H5ErrorCode;
use crate::globals::{H5E_CALLBACK, H5E_PLIST};
use crate::internal_prelude::*;
use lzf_sys::{lzf_compress, lzf_decompress, LZF_VERSION};

const LZF_FILTER_NAME: &[u8] = b"lzf\0";
pub const LZF_FILTER_ID: H5Z_filter_t = 32000;
Expand Down Expand Up @@ -37,7 +38,7 @@ lazy_static! {
}

pub fn register_lzf() -> Result<(), &'static str> {
(*LZF_INIT).clone()
*LZF_INIT
}

extern "C" fn set_local_lzf(dcpl_id: hid_t, type_id: hid_t, _space_id: hid_t) -> herr_t {
Expand Down Expand Up @@ -80,7 +81,7 @@ extern "C" fn set_local_lzf(dcpl_id: hid_t, type_id: hid_t, _space_id: hid_t) ->
if bufsize == 0 {
return -1;
}
for &chunkdim in chunkdims[..(ndims as usize)].iter() {
for &chunkdim in &chunkdims[..(ndims as usize)] {
bufsize *= chunkdim as size_t;
}
values[2] = bufsize as _;
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/hl/plist/dataset_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl DatasetAccessBuilder {
pub fn finish(&self) -> Result<DatasetAccess> {
h5lock!({
let mut plist = DatasetAccess::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/hl/plist/dataset_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ impl DatasetCreateBuilder {
pub fn finish(&self) -> Result<DatasetCreate> {
h5lock!({
let mut plist = DatasetCreate::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions hdf5/src/hl/plist/file_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ impl FileAccessBuilder {
pub fn finish(&self) -> Result<FileAccess> {
h5lock!({
let mut plist = FileAccess::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down Expand Up @@ -1587,7 +1587,7 @@ impl FileAccess {
}
let relax = relax > 0;
let drv = MultiDriver { files, layout, relax };
drv.validate().map(|_| drv)
drv.validate().map(|()| drv)
}

#[doc(hidden)]
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/hl/plist/file_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ impl FileCreateBuilder {
pub fn finish(&self) -> Result<FileCreate> {
h5lock!({
let mut plist = FileCreate::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/hl/plist/link_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl LinkCreateBuilder {
pub fn finish(&self) -> Result<LinkCreate> {
h5lock!({
let mut plist = LinkCreate::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions hdf5/src/hl/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn check_coords(coords: &Array2<Ix>, shape: &[Ix]) -> Result<()> {
let ndim = coords.shape()[1];
ensure!(ndim == shape.len(), "Slice ndim ({}) != shape ndim ({})", ndim, shape.len());
for (i, &dim) in shape.iter().enumerate() {
for &d in coords.slice(s![.., i]).iter() {
for &d in coords.slice(s![.., i]) {
ensure!(d < dim, "Index {} out of bounds for axis {} with size {}", d, i, dim);
}
}
Expand Down Expand Up @@ -674,7 +674,7 @@ impl From<Vec<SliceOrIndex>> for Hyperslab {
}

impl From<()> for Hyperslab {
fn from(_: ()) -> Self {
fn from((): ()) -> Self {
vec![].into()
}
}
Expand Down Expand Up @@ -929,7 +929,7 @@ impl From<RangeFull> for Selection {
}

impl From<()> for Selection {
fn from(_: ()) -> Self {
fn from((): ()) -> Self {
Hyperslab::from(()).into()
}
}
Expand Down
7 changes: 4 additions & 3 deletions hdf5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mod export {
AttributeBuilderEmptyShape, ByteReader, Container, Conversion, Dataset, DatasetBuilder,
DatasetBuilderData, DatasetBuilderEmpty, DatasetBuilderEmptyShape, Dataspace, Datatype,
File, FileBuilder, Group, LinkInfo, LinkType, Location, LocationInfo, LocationToken,
LocationType, Object, PropertyList, Reader, Writer,
LocationType, Object, OpenMode, PropertyList, Reader, Writer,
},
};

Expand Down Expand Up @@ -145,20 +145,21 @@ mod hl;

mod internal_prelude {
pub use libc::size_t;
#[allow(unused_imports)]
pub use std::os::raw::{c_char, c_double, c_int, c_long, c_uint, c_void};

pub use hdf5_sys::{
h5::{haddr_t, hbool_t, herr_t, hsize_t},
h5i::H5I_type_t::{self, *},
h5i::{hid_t, H5I_INVALID_HID},
h5p::H5P_DEFAULT,
h5s::{H5S_ALL, H5S_UNLIMITED},
h5s::H5S_ALL,
};

pub use crate::{
class::ObjectClass,
dim::Dimension,
error::{h5check, H5ErrorCode},
error::h5check,
export::*,
handle::Handle,
hl::plist::PropertyListClass,
Expand Down