use std::convert::TryFrom;
use nix::libc;
use crate::process::Status;
use crate::ParseStatusError;
const SIDL: libc::c_char = 1;
const SRUN: libc::c_char = 2;
const SSLEEP: libc::c_char = 3;
const SSTOP: libc::c_char = 4;
const SZOMB: libc::c_char = 5;
impl TryFrom<libc::c_char> for Status {
type Error = ParseStatusError;
fn try_from(value: libc::c_char) -> Result<Status, Self::Error> {
match value {
SIDL => Ok(Status::Idle),
SRUN => Ok(Status::Running),
SSLEEP => Ok(Status::Sleeping),
SSTOP => Ok(Status::Stopped),
SZOMB => Ok(Status::Zombie),
other => Err(ParseStatusError::IncorrectChar {
contents: other.to_string(),
}),
}
}
}