pub mod allocator;
pub(crate) mod chunk_grid;
pub mod file_handle;
pub(crate) mod free_space_io;
pub(crate) mod hyperslab;
pub mod locking;
pub(crate) mod object_header_io;
pub mod reader;
pub mod swmr;
pub(crate) mod symbol_table_io;
pub mod writer;
pub use reader::Hdf5Reader;
pub use swmr::SwmrWriter;
pub use writer::Hdf5Writer;
#[derive(Debug, Clone)]
pub(crate) struct FileMeta {
pub(crate) ctx: crate::format::FormatContext,
pub(crate) btree: crate::format::btree_v1::BTreeV1Config,
pub(crate) sohm: Option<crate::format::sohm::SohmMasterTable>,
}
#[derive(Debug)]
pub enum IoError {
Io(std::io::Error),
Format(crate::format::FormatError),
NotFound(String),
InvalidState(String),
Unsupported(String),
DanglingLink {
link: String,
target: String,
},
ExternalFileNotFound {
link: String,
file: String,
searched: Vec<String>,
},
}
impl From<std::io::Error> for IoError {
fn from(e: std::io::Error) -> Self {
Self::Io(e)
}
}
impl From<crate::format::FormatError> for IoError {
fn from(e: crate::format::FormatError) -> Self {
Self::Format(e)
}
}
impl From<crate::format::selection::HyperslabError> for IoError {
fn from(e: crate::format::selection::HyperslabError) -> Self {
Self::InvalidState(e.to_string())
}
}
impl std::fmt::Display for IoError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Io(e) => write!(f, "I/O error: {}", e),
Self::Format(e) => write!(f, "format error: {}", e),
Self::NotFound(s) => write!(f, "not found: {}", s),
Self::InvalidState(s) => write!(f, "invalid state: {}", s),
Self::Unsupported(s) => write!(f, "unsupported: {}", s),
Self::DanglingLink { link, target } => write!(
f,
"link '{}' points to '{}', which does not exist",
link, target
),
Self::ExternalFileNotFound {
link,
file,
searched,
} => write!(
f,
"external link '{}' names the file '{}', which could not be opened (tried: {})",
link,
file,
searched.join(", ")
),
}
}
}
impl std::error::Error for IoError {}
pub type IoResult<T> = Result<T, IoError>;