use thiserror::Error;
#[derive(Debug, Error)]
pub enum WireError {
#[error("Failed to serialize value: {0}")]
SerializationError(String),
#[error("Failed to deserialize value: {0}")]
DeserializationError(String),
#[error("Invalid value: {0}")]
InvalidValue(String),
#[error("Type mismatch: expected {expected}, got {actual}")]
TypeMismatch { expected: String, actual: String },
#[error("Missing required field: {0}")]
MissingField(String),
#[error("Format not found: {0}")]
FormatNotFound(String),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
}
pub type Result<T> = std::result::Result<T, WireError>;
impl From<rmp_serde::encode::Error> for WireError {
fn from(e: rmp_serde::encode::Error) -> Self {
WireError::SerializationError(e.to_string())
}
}
impl From<rmp_serde::decode::Error> for WireError {
fn from(e: rmp_serde::decode::Error) -> Self {
WireError::DeserializationError(e.to_string())
}
}