summaryrefslogtreecommitdiff
path: root/src/codec/error.rs
blob: 7d88d55fd92d710ca68ede6ca38a59468ee8a8e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use thiserror::Error;

#[derive(Debug, Error)]
pub enum CodecError {
    #[error("io error: {0}")]
    IoError(#[from] std::io::Error),

    #[error("{0}")]
    Custom(String),
}

pub type Result<T> = core::result::Result<T, CodecError>;

impl From<&str> for CodecError {
    fn from(value: &str) -> Self {
        Self::Custom(value.to_string())
    }
}

impl From<String> for CodecError {
    fn from(value: String) -> Self {
        Self::Custom(value)
    }
}