hash_value/
error.rs

1use std::fmt::{Display, Formatter};
2
3#[derive(Debug, Clone)]
4pub struct Error {
5    message: String,
6}
7
8pub type Result<T> = std::result::Result<T, Error>;
9
10impl serde::de::Error for Error {
11    fn custom<T>(msg: T) -> Self
12    where
13        T: Display,
14    {
15        Self {
16            message: msg.to_string(),
17        }
18    }
19}
20
21impl serde::ser::Error for Error {
22    fn custom<T>(msg: T) -> Self
23    where
24        T: Display,
25    {
26        Self {
27            message: msg.to_string(),
28        }
29    }
30}
31
32impl std::error::Error for Error {}
33
34impl Display for Error {
35    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
36        f.write_str(self.message.as_str())
37    }
38}