transaction-processor 0.0.1

Write transaction processors for Wavelet in Rust.
Documentation
#[derive(Copy, Clone, Debug)]
#[repr(u32)]
pub enum StoreId {
    Global = 0,  // the global key-value store.
    Account = 1, // the account state tree.
}

#[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,
            },
        }
    }
}