pax_language/deserializer/
error.rs1use std;
2use std::fmt::{self, Display};
3
4use serde::{de, ser};
5
6pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Debug, Clone)]
10pub enum Error {
12 Message(String),
13 UnsupportedType(String),
14}
15
16impl ser::Error for Error {
17 fn custom<T: Display>(msg: T) -> Self {
18 Error::Message(msg.to_string())
19 }
20}
21
22impl de::Error for Error {
23 fn custom<T: Display>(msg: T) -> Self {
24 Error::Message(msg.to_string())
25 }
26}
27
28impl Display for Error {
29 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
30 match self {
31 Error::Message(msg) => formatter.write_str(msg),
32 Error::UnsupportedType(t) => {
33 formatter.write_str(format!("unsupported type: {}", t).as_str())
34 }
35 }
36 }
37}
38
39impl std::error::Error for Error {}