use dynpatch_interface::PatchError;
use std::path::PathBuf;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
#[error("Failed to load library: {path}")]
LibraryLoadError {
path: PathBuf,
#[source]
source: libloading::Error,
},
#[error("Symbol not found: {symbol}")]
SymbolNotFound {
symbol: String,
},
#[error("ABI validation failed: {0}")]
AbiValidationFailed(String),
#[error("Version mismatch: expected {expected}, found {found}")]
VersionMismatch {
expected: String,
found: String,
},
#[error("Type layout mismatch for {type_name}: expected size={expected_size} align={expected_align}, found size={found_size} align={found_align}")]
TypeLayoutMismatch {
type_name: String,
expected_size: usize,
expected_align: usize,
found_size: usize,
found_align: usize,
},
#[error("Patch initialization failed (code {code}): {message}")]
InitializationFailed {
code: i32,
message: String,
},
#[error("No patch loaded")]
NoPatchLoaded,
#[error("No previous patch to rollback to")]
NoPreviousPatch,
#[error("Invalid patch format: {0}")]
InvalidPatchFormat(String),
#[error("Patch interface error: {0}")]
PatchInterface(#[from] PatchError),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Other error: {0}")]
Other(String),
}
impl From<String> for Error {
fn from(s: String) -> Self {
Error::Other(s)
}
}
impl From<&str> for Error {
fn from(s: &str) -> Self {
Error::Other(s.to_string())
}
}