1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
use std::convert::TryFrom; use nature_common::NatureError; pub enum TaskType { Store = 1, Convert = 2, Batch = 11, } impl TryFrom<i8> for TaskType { type Error = NatureError; fn try_from(value: i8) -> Result<Self, Self::Error> { match value { 1 => Ok(TaskType::Store), 2 => Ok(TaskType::Convert), 11 => Ok(TaskType::Batch), _ => Err(NatureError::VerifyError(format!("undefined [{}] for `TaskType`", value))) } } }