1use std::fmt;
5
6#[derive(Debug)]
8pub struct Error {
9 message: String,
10}
11
12impl Error {
13 pub fn new(message: impl Into<String>) -> Self {
14 Self {
15 message: message.into(),
16 }
17 }
18}
19
20impl fmt::Display for Error {
21 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
22 formatter.write_str(&self.message)
23 }
24}
25
26impl std::error::Error for Error {}
27
28impl From<std::io::Error> for Error {
29 fn from(error: std::io::Error) -> Self {
30 Self::new(error.to_string())
31 }
32}
33
34impl From<serde_json::Error> for Error {
35 fn from(error: serde_json::Error) -> Self {
36 Self::new(error.to_string())
37 }
38}
39
40pub type Result<Output = ()> = std::result::Result<Output, Error>;