rscel
RsCel is a CEL evaluator written in Rust. CEL is a Turing-incomplete language that can be used to evaluate a user-provided expression. The language specification can be found here.
The design goals of this project are as follows:
- Isolated execution of CEL expressions
- Flexible enough to allow for a user to bend the spec if needed
- Can be used as a WASM depenedency (or other FFI)
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 CelValue
let res = ctx.exec.unwrap; // CelValue::Int(6)
assert_eq!;
As of 0.10.0, binding protobuf messages from the protobuf crate is now available! Given the following protobuf message:
message Point {
int32 x = 1;
int32 y = 2;
}
The following code can be used to evaluate a CEL expression on a Point message:
use ;
// currently rscel requires protobuf messages to be in a box
let p = Boxnew;
p.x = 4;
p.y = 5;
let mut ctx = new;
let mut exec_ctx = new;
ctx.add_program_str.unwrap;
exec_ctx.bind_protobuf_msg;
assert_eq!;