use alloc::string::{String, ToString};
use core::fmt::{Debug, Display, Formatter, Result};
use serde::ser::{Error as SerError, StdError};
#[derive(Debug)]
pub enum Error<T> {
Io(T),
Value(String),
}
impl<T> From<T> for Error<T> {
#[inline]
fn from(value: T) -> Self {
Error::Io(value)
}
}
impl<T: Debug> Display for Error<T> {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{:?}", self)
}
}
impl<T: Debug> StdError for Error<T> {}
impl<T: Debug> SerError for Error<T> {
fn custom<U: Display>(msg: U) -> Self {
Error::Value(msg.to_string())
}
}