use std::process::{ExitCode, Termination};
use crate::err::Error;
#[repr(u8)]
pub enum ProcRes {
Success,
Error(Error)
}
impl Termination for ProcRes {
fn report(self) -> ExitCode {
match self {
Self::Success => {
ExitCode::from(0)
}
Self::Error(e) => {
eprintln!("Abnormal termination: {e}");
ExitCode::from(1)
}
}
}
}
impl<T> From<Result<T, Error>> for ProcRes {
fn from(res: Result<T, Error>) -> Self {
match res {
Ok(_) => Self::Success,
Err(e) => Self::Error(e)
}
}
}