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 { ProcRes::Success => { //eprintln!("Process terminated successfully"); ExitCode::from(0) } ProcRes::Error(e) => { eprintln!("Abnormal termination: {}", e); ExitCode::from(1) } } } } impl From> for ProcRes { fn from(res: Result) -> ProcRes { match res { Ok(_) => ProcRes::Success, Err(e) => ProcRes::Error(e) } } } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :