pub mod attrs;
pub mod data;
pub mod file;
pub mod graph;
pub mod ops;
mod window;
pub use attrs::AttrValue;
pub use hdf5::{Dataset, File, Group, Location};
pub fn init() {
hdf5::sync::sync(|| {
unsafe {
medh5_sys::register_blosc2_filter();
medh5_sys::register_zstd_filter();
}
});
}
pub const CLOSED: &str = "the file this object was read from has been closed";
pub fn alive(obj: &hdf5::Location) -> crate::Result<()> {
if obj.is_valid() {
Ok(())
} else {
Err(crate::Error::File(CLOSED.into()))
}
}
pub(crate) fn locked<T>(f: impl FnOnce() -> T) -> T {
hdf5::sync::sync(f)
}
pub fn relative_name(name: &str, root: &str) -> String {
let base = if root == "/" { "/".to_string() } else { format!("{}/", root.trim_end_matches('/')) };
match name.strip_prefix(&base) {
Some(rest) => rest.to_string(),
None => name.trim_start_matches('/').to_string(),
}
}
pub fn basename(name: &str) -> &str {
name.rsplit('/').next().unwrap_or(name)
}