1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::{borrow::Cow, fmt};

#[derive(Debug)]
pub enum Error {
    Todo(Cow<'static, str>),
}

pub type Result<T> = std::result::Result<T, Error>;

impl From<&'static str> for Error {
    fn from(err: &'static str) -> Error {
        Error::Todo(err.into())
    }
}

impl From<String> for Error {
    fn from(err: String) -> Error {
        Error::Todo(err.into())
    }
}

impl From<data_encoding::DecodeError> for Error {
    fn from(err: data_encoding::DecodeError) -> Error {
        err.to_string().into()
    }
}

impl std::error::Error for Error {}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Error::Todo(s) => write!(f, "TODO cbor-diag::Error: {s}"),
        }
    }
}