//! Error types for medical imaging I/O operations. use thiserror::Error; /// Errors that can occur when reading or writing medical image files. #[derive(Error, Debug)] pub enum MedicalIoError { /// IO error during file operations #[error("IO error: {0}")] Io(#[from] std::io::Error), /// Invalid NIfTI header magic bytes #[error("Invalid NIfTI magic bytes: expected 'n+1' or 'ni1', got {0:?}")] InvalidNiftiMagic(Vec), /// Invalid NIfTI header size #[error("Invalid NIfTI header size: expected 348 (NIfTI-1) or 540 (NIfTI-2), got {0}")] InvalidHeaderSize(i32), /// Unsupported NIfTI data type #[error("Unsupported NIfTI data type code: {0}")] UnsupportedDataType(i16), /// Invalid dimensions #[error("Invalid dimensions: {0}")] InvalidDimensions(String), /// Compression error #[error("Compression error: {0}")] Compression(String), /// Decompression error #[error("Decompression error: {0}")] Decompression(String), /// Data type mismatch #[error("Data type mismatch: expected {expected}, got {actual}")] DataTypeMismatch { expected: String, actual: String }, /// File not found #[error("File not found: {0}")] FileNotFound(String), /// Invalid file extension #[error("Invalid file extension: expected .nii or .nii.gz, got {0}")] InvalidExtension(String), /// Memory mapping error #[error("Memory mapping error: {0}")] MemoryMap(String), /// Invalid transform #[error("Invalid transform: {0}")] InvalidTransform(String), /// Parse error #[error("Parse error: {0}")] Parse(String), } /// Result type for medical imaging I/O operations. pub type Result = std::result::Result;