#[derive(Copy, Clone, Debug)]
#[repr(u32)]
pub enum StoreId {
Global = 0, Account = 1, }
#[derive(Copy, Clone, Eq, PartialEq)]
#[repr(u32)]
pub enum InternalProcessResult {
Ok = 0,
Err = 1,
Ignore = 2,
}
#[derive(Clone, Debug)]
pub enum ProcessError {
Generic,
NotFound,
InvalidData,
InvalidState,
Overflow,
Custom(String),
Ignore,
}
pub type ProcessResult<T> = Result<T, ProcessError>;
impl From<InternalProcessResult> for Result<(), ProcessError> {
fn from(other: InternalProcessResult) -> Result<(), ProcessError> {
match other {
InternalProcessResult::Ok => Ok(()),
InternalProcessResult::Err => Err(ProcessError::Generic),
InternalProcessResult::Ignore => Err(ProcessError::Ignore),
}
}
}
impl From<Result<(), ProcessError>> for InternalProcessResult {
fn from(other: Result<(), ProcessError>) -> InternalProcessResult {
match other {
Ok(()) => InternalProcessResult::Ok,
Err(e) => match e {
ProcessError::Ignore => InternalProcessResult::Ignore,
_ => InternalProcessResult::Err,
},
}
}
}