qrexec_binds/
errors.rs

1use std::{
2    error::Error,
3    fmt::{
4        Display,
5        Formatter,
6        self,
7    },
8    io,
9};
10use anyhow;
11
12pub type QRXRes<T> = Result<T, QRXErr>;
13
14#[derive(Debug)]
15pub enum QRXErr {
16    Io(io::Error), 
17    Anyhow(anyhow::Error), 
18}
19
20impl Error for QRXErr {}
21
22impl Display for QRXErr {
23    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
24        match self {
25            Self::Io(io_err) => write!(f, "{}", io_err),
26            Self::Anyhow(ah_err) => write!(f, "{}", ah_err), 
27        }  
28    }
29}
30
31impl From<anyhow::Error> for QRXErr {
32    fn from(err: anyhow::Error) -> Self {
33        return Self::Anyhow(err);
34    }
35}
36
37impl From<io::Error> for QRXErr {
38    fn from(err: io::Error) -> Self {
39        return Self::Io(err);
40    }
41}