rscel
RsCel is a CEL evaluator written in Rust. CEL is a google project that describes a turing-incomplete language that can be used to evaluate a user provdided expression. The language specification can be found here.
The design goals of this project were are as follows:
- Flexible enough to allow for a user to bend the spec if needed
- Sandbox'ed in such a way that only specific values can be bound
- Can be used as a wasm depenedency (or other ffi)
While Google's CEL spec was designed around the protobuf message, I decided to focus on using the JSON message instead (CEL spec specifies how to convert from JSON to CEL types).
The basic example of how to use:
use ;
let mut ctx = new;
let mut exec_ctx = new;
ctx.add_program_str.unwrap;
exec_ctx.bind_param; // convert to serde_json::Value
let res = ctx.exec.unwrap; // ValueCell::Int(6)
assert!;
Current Benchmark Times
Bench Run | Time |
---|---|
Run One No Binding: | 0.000310S |
Run Many No Binding: | 0.003657S |
Run One With Binding: | 0.000033S |
Run Many With Bindings: | 0.004281S |
Build Many: | 0.002312S |
Build Many With Bindings: | 0.051369S |