med64 0.0.2

Headless MED64 electrophysiology toolkit: .modat I/O, spike/burst analysis, assays, spike-rate maps, and CSV/HTML/SVG/HDF5 export
Documentation
use std::path::PathBuf;
use thiserror::Error;

use crate::format::FileFormat;

#[derive(Debug, Error)]
pub enum Med64Error {
    #[error("I/O error while reading {path}: {source}")]
    Io {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    #[error("I/O error while writing {path}: {source}")]
    WriteIo {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    #[error("unexpected end of file at offset {offset}")]
    UnexpectedEof { offset: u64 },

    #[error("invalid header in {path}: {message}")]
    InvalidHeader { path: PathBuf, message: String },

    #[error("invalid data block {block_index} in {path}: {message}")]
    InvalidBlock { path: PathBuf, block_index: usize, message: String },

    #[error("failed to parse moflo workflow {path}: {message}")]
    InvalidMoflo { path: PathBuf, message: String },

    #[error("unsupported conversion from {from:?} to {to:?}")]
    UnsupportedConversion { from: FileFormat, to: FileFormat },

    #[error("format {format:?} cannot be written")]
    NotWritable { format: FileFormat },

    #[error("invalid write: {message}")]
    InvalidWrite { message: String },
}

pub type Result<T> = std::result::Result<T, Med64Error>;