use std::fmt;
use serde::de;
use snafu::Snafu;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Snafu, Clone, PartialEq)]
#[snafu(visibility(pub))]
pub enum Error {
#[snafu(display("{message}"))]
Message { message: String },
#[snafu(display("type mismatch: expected {expected}, found {found}"))]
TypeMismatch { expected: String, found: String },
#[snafu(display("missing field: {field}"))]
MissingField { field: String },
#[snafu(display("invalid value '{value}' for type {expected_type}"))]
InvalidValue {
value: String,
expected_type: String,
},
#[snafu(display("unsupported operation: {operation}"))]
UnsupportedOperation { operation: String },
#[snafu(display("index {index} out of bounds for length {length}"))]
IndexOutOfBounds { index: usize, length: usize },
#[snafu(display("key not found: {key}"))]
KeyNotFound { key: String },
}
impl de::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Self {
Error::Message {
message: msg.to_string(),
}
}
}