#![forbid(unsafe_code)] use std::fmt::{ Display, Formatter }; pub type Result = std::result::Result; #[derive(Debug)] pub enum Error { CommandLine(::clap::error::Error), Internal(String), IO(std::io::Error), UTF8, } impl From for Error { fn from(value: std::io::Error) -> Self { Error::IO(value) } } impl From<::clap::error::Error> for Error { fn from(value: ::clap::error::Error) -> Self { Error::CommandLine(value) } } impl From for Error { fn from(_value: std::string::FromUtf8Error) -> Self { Error::UTF8 } } impl Display for Error { fn fmt(&self, fmt: &mut Formatter<'_>) -> std::fmt::Result { match self { Error::CommandLine(error) => { write!(fmt, "{}", error.to_string()) }, Error::Internal(string) => { write!(fmt, "{}", string) }, Error::IO(error) => { write!(fmt, "{}", error.to_string()) }, Error::UTF8 => { write!(fmt, "Invalid UTF8 received") }, } } }