rush_wasm_engine 0.1.0

The rules engine is based on the rete algorithm
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::WasmLoader;
use anyhow::anyhow;
use wd_tools::{PFErr, PFOk};

pub const WASM_LOADER_FILE: &'static str = "wasm_file:";
pub struct WasmLoaderFile;

impl WasmLoader for WasmLoaderFile {
    fn load(&self, _rule_name: String, mut file: String) -> anyhow::Result<Vec<u8>> {
        if !file.starts_with(WASM_LOADER_FILE) {
            return anyhow!("expect loader tag:{} not found", WASM_LOADER_FILE).err();
        }
        let path = file.split_off(WASM_LOADER_FILE.len());
        let path = path.trim_matches(|x| " \t\r\n".contains(x));
        let bytes = std::fs::read(path)?;
        bytes.ok()
    }
}