1use alloc::string::{String, ToString};
4use core::fmt::{Debug, Display, Formatter, Result};
5
6use serde::ser::{Error as SerError, StdError};
7
8#[derive(Debug)]
10pub enum Error<T> {
11    Io(T),
15
16    Value(String),
20}
21
22impl<T> From<T> for Error<T> {
23    #[inline]
24    fn from(value: T) -> Self {
25        Error::Io(value)
26    }
27}
28
29impl<T: Debug> Display for Error<T> {
30    #[inline]
31    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
32        write!(f, "{:?}", self)
33    }
34}
35
36impl<T: Debug> StdError for Error<T> {}
37
38impl<T: Debug> SerError for Error<T> {
39    fn custom<U: Display>(msg: U) -> Self {
40        Error::Value(msg.to_string())
41    }
42}