use fidius_core::PluginError;
#[derive(Debug, thiserror::Error)]
pub enum LoadError {
#[error("library not found: {path}")]
LibraryNotFound { path: String },
#[error("symbol 'fidius_get_registry' not found in {path}")]
SymbolNotFound { path: String },
#[error("invalid magic bytes (expected FIDIUS\\0\\0)")]
InvalidMagic,
#[error("incompatible registry version: got {got}, expected {expected}")]
IncompatibleRegistryVersion { got: u32, expected: u32 },
#[error("incompatible ABI version: got {got}, expected {expected}")]
IncompatibleAbiVersion { got: u32, expected: u32 },
#[error("interface hash mismatch: got {got:#x}, expected {expected:#x}")]
InterfaceHashMismatch { got: u64, expected: u64 },
#[error("buffer strategy mismatch: plugin uses {got}, host expects {expected}")]
BufferStrategyMismatch {
got: fidius_core::descriptor::BufferStrategyKind,
expected: fidius_core::descriptor::BufferStrategyKind,
},
#[error("architecture mismatch: expected {expected}, got {got}")]
ArchitectureMismatch { expected: String, got: String },
#[error("unknown buffer strategy discriminant: {value}")]
UnknownBufferStrategy { value: u8 },
#[error("signature verification failed for {path}")]
SignatureInvalid { path: String },
#[error("signature required but no .sig file found for {path}")]
SignatureRequired { path: String },
#[error("plugin '{name}' not found")]
PluginNotFound { name: String },
#[error("libloading error: {0}")]
LibLoading(#[from] libloading::Error),
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("python load failed: {0}")]
PythonLoad(String),
}
#[derive(Debug, thiserror::Error)]
pub enum CallError {
#[error("serialization error: {0}")]
Serialization(String),
#[error("deserialization error: {0}")]
Deserialization(String),
#[error("plugin error: {0}")]
Plugin(PluginError),
#[error("plugin panicked: {0}")]
Panic(String),
#[error("buffer too small")]
BufferTooSmall,
#[error("method not implemented (capability bit {bit} not set)")]
NotImplemented { bit: u32 },
#[error("invalid method index {index} (plugin has {count} method(s))")]
InvalidMethodIndex { index: usize, count: u32 },
#[error("unknown FFI status code: {code}")]
UnknownStatus { code: i32 },
}