pub const ERR_SUCCESS: i32 = 1;
pub const ERR_GENERIC: i32 = 0;
pub const ERR_DB_NOT_FOUND: i32 = -1;
pub const ERR_INVALID_PATH: i32 = -2;
pub const ERR_IO: i32 = -3;
pub const ERR_SERIALIZATION: i32 = -4;
pub const ERR_KEY_NOT_FOUND: i32 = -5;
pub const ERR_TYPE_MISMATCH: i32 = -6;
pub const ERR_EMPTY_KEY: i32 = -7;
pub const ERR_KEY_TOO_LONG: i32 = -8;
pub const ERR_INTERNAL_PANIC: i32 = -100;
pub const ERR_GPU_UNAVAILABLE: i32 = -50;
pub const ERR_GPU_OUT_OF_MEMORY: i32 = -51;
pub type Result<T> = std::result::Result<T, SynaError>;
#[derive(Debug, thiserror::Error)]
pub enum SynaError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(#[from] bincode::Error),
#[error("Database not found: {0}")]
NotFound(String),
#[error("Invalid path: {0}")]
InvalidPath(String),
#[error("Key not found: {0}")]
KeyNotFound(String),
#[error("Corrupted entry at offset {0}")]
CorruptedEntry(u64),
#[error("Decompression failed")]
DecompressionFailed,
#[error("Empty key is not allowed")]
EmptyKey,
#[error("Key too long: {0} bytes (max 65535)")]
KeyTooLong(usize),
#[error("Invalid dimensions: {0} (must be 64-8192)")]
InvalidDimensions(u16),
#[error("Dimension mismatch: expected {expected}, got {got}")]
DimensionMismatch {
expected: u16,
got: u16,
},
#[error("Dimension mismatch: expected {expected}, got {got}")]
DimensionMismatchUsize {
expected: usize,
got: usize,
},
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("IO error: {0}")]
IoError(String),
#[error("Corrupted HNSW index: {0}")]
CorruptedIndex(String),
#[error("Shape mismatch: data size {data_size} does not match expected size {expected_size} for shape")]
ShapeMismatch {
data_size: usize,
expected_size: usize,
},
#[error("Type conversion error: cannot convert {from_type} to {to_type}")]
TypeConversion {
from_type: &'static str,
to_type: &'static str,
},
#[error("Model not found: {0}")]
ModelNotFound(String),
#[error("Checksum mismatch: expected {expected}, got {got}")]
ChecksumMismatch {
expected: String,
got: String,
},
#[error("Run not found: {0}")]
RunNotFound(String),
#[error("Run already ended: {0}")]
RunAlreadyEnded(String),
#[error("GPU unavailable: {0}")]
GpuUnavailable(String),
#[error("GPU out of memory: {0}")]
GpuOutOfMemory(String),
#[error("Index error: {0}")]
IndexError(String),
}