use serde::de;
use serde::ser;
use std::fmt;
use thiserror::Error;
#[derive(Debug, Clone, Error)]
pub enum Error {
#[error("cannot serialize non primitive type {0}")]
ImpossibleSerialization(&'static str),
#[error("cannot deserialize to non primitive type {0}")]
ImpossibleDeserialization(&'static str),
#[error("cannot parse {0}: {1}")]
Parse(&'static str, String),
#[error("{0}")]
Message(String),
}
impl ser::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Error {
Error::Message(msg.to_string())
}
}
impl de::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Error {
Error::Message(msg.to_string())
}
}