mod chunk;
mod dataset;
mod index;
pub mod serde;
pub use self::index::{GroupIndex, Index};
pub use chunk::{Chunk, ULE};
pub use dataset::{Dataset, DatasetD, DatasetExt, Datatype};
pub trait IntoIndex {
type Indexed;
fn index(&self) -> anyhow::Result<Self::Indexed>;
}
impl IntoIndex for hdf5::File {
type Indexed = Index<'static>;
fn index(&self) -> anyhow::Result<Self::Indexed> {
self.try_into()
}
}
impl IntoIndex for hdf5::Dataset {
type Indexed = DatasetD<'static>;
fn index(&self) -> anyhow::Result<Self::Indexed> {
DatasetD::index(self)
}
}
#[cfg(feature = "netcdf")]
impl IntoIndex for netcdf::File {
type Indexed = Index<'static>;
fn index(&self) -> anyhow::Result<Self::Indexed> {
self.try_into()
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn into_idx_file() {
let hf = hdf5::File::open("tests/data/dmrpp/chunked_twoD.h5").unwrap();
let i = hf.index().unwrap();
println!("index: {:#?}", i);
}
#[test]
#[cfg(feature = "netcdf")]
fn into_idx_netcdf() {
let hf = netcdf::open("tests/data/coads_climatology.nc4").unwrap();
let i = hf.index().unwrap();
println!("index: {:#?}", i);
}
#[test]
fn into_idx_dataset() {
let hf = hdf5::File::open("tests/data/coads_climatology.nc4").unwrap();
let ds = hf.dataset("SST").unwrap();
let i = ds.index().unwrap();
println!("dataset index: {:#?}", i);
}
}