use std::fmt;
use serde::ser;
use snafu::Snafu;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Snafu, Clone, PartialEq)]
pub enum Error {
#[snafu(display("{message}"))]
Message { message: String },
#[snafu(display("unsupported type: {type_name}"))]
UnsupportedType { type_name: String },
#[snafu(display("invalid key type: expected string, found {found}"))]
InvalidKeyType { found: String },
#[snafu(display("sequence length mismatch: expected {expected}, found {found}"))]
SequenceLengthMismatch { expected: usize, found: usize },
#[snafu(display("map key must be a string"))]
MapKeyMustBeString,
#[snafu(display("enum variant '{variant}' serialization failed"))]
EnumVariantFailed { variant: String },
#[snafu(display("nested serialization error: {source}"))]
NestedSerialization { source: Box<Error> },
}
impl ser::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Self {
Error::Message {
message: msg.to_string(),
}
}
}