1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Error, Debug)]
10pub enum Error {
11 #[error("IO error: {0}")]
12 IOError(#[from] std::io::Error),
13 #[error("Invalid data: {0}")]
14 InvalidData(String),
15}
16
17impl serde::ser::Error for Error {
18 fn custom<T: std::fmt::Display>(msg: T) -> Self {
19 Error::InvalidData(msg.to_string())
20 }
21}
22
23impl serde::de::Error for Error {
24 fn custom<T: std::fmt::Display>(msg: T) -> Self {
25 Error::InvalidData(msg.to_string())
26 }
27}