transaction-processor 0.0.1

Write transaction processors for Wavelet in Rust.
Documentation
use types::*;

pub trait IfNotFound {
    type Target;
    fn if_not_found<F: FnOnce() -> Self::Target>(self, f: F) -> ProcessResult<Self::Target>;
}

impl<T> IfNotFound for ProcessResult<T> {
    type Target = T;
    fn if_not_found<F: FnOnce() -> T>(self, f: F) -> ProcessResult<T> {
        match self {
            Ok(v) => Ok(v),
            Err(e) => match e {
                ProcessError::NotFound => Ok(f()),
                _ => Err(e),
            },
        }
    }
}

pub fn log(msg: &str) {
    let msg = msg.as_bytes();
    unsafe {
        ::sys::_log(msg.as_ptr(), msg.len());
    }
}