use std::path::PathBuf;
use crate::types::Architecture;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Failed to open file '{path}': {source}")]
FileOpen { path: PathBuf, source: std::io::Error },
#[error("Failed to parse PE/COFF file: {0}")]
PeParse(String),
#[error("Export directory not found")]
NoExportDirectory,
#[error("Export table is corrupted or invalid")]
InvalidExportTable,
#[error("Expected {expected} exports, found {actual}")]
ExportCountMismatch { expected: usize, actual: usize },
#[error("Missing required export(s): {0}")]
MissingExport(String),
#[error("Export name mismatch: expected '{expected}', found '{actual}'")]
NameMismatch { expected: String, actual: String },
#[error("Export ordinal mismatch: name '{name}', expected ordinal {expected}, found {actual}")]
OrdinalMismatch { name: String, expected: u32, actual: u32 },
#[error("Not a valid DLL/EXE file")]
InvalidFileFormat,
#[error("Architecture mismatch: expected {expected}, found {actual}")]
ArchMismatch {
expected: Architecture,
actual: Architecture,
},
#[error("Not a DLL file")]
NotADll,
#[error("Windows registry error: {0}")]
Registry(String),
#[error("Export not found: {0}")]
ExportNotFound(String),
#[error("No exports found in DLL")]
NoExports,
#[error("UTF-8 decoding error: {0}")]
Utf8(#[from] std::string::FromUtf8Error),
#[error("NUL character found in export name")]
NulInName,
#[cfg(feature = "serde")]
#[error("JSON serialization error: {0}")]
Json(#[from] serde_json::Error),
}