use std::{fmt, io}; #[derive(Debug)] pub enum Error { IO(String), Qsu(String) } impl std::error::Error for Error {} impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Self::IO(s) => write!(f, "I/O error; {s}"), Self::Qsu(s) => write!(f, "qsu error; {s}") } } } impl From for Error { fn from(err: io::Error) -> Self { Self::IO(err.to_string()) } } impl From> for Error { fn from(err: qsu::CbErr) -> Self { Self::Qsu(err.to_string()) } } /* /// Convenience converter used to pass application-defined errors from the /// inner callback back out from the qsu runtime. impl From for qsu::Error { fn from(err: Error) -> qsu::Error { qsu::Error::app(err) } } */ /// Convenience converter for mapping application-specific errors to /// `qsu::CbErr::App`. impl From for qsu::CbErr { fn from(err: Error) -> Self { Self::App(err) } } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :