fsm-guards 0.1.0

Fuel-metered JSONLogic guard evaluation with per-call custom operators — forked from jsonlogic-rs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub mod eval;

use crate::ctx::EvalCtx;
use crate::error::ApplyError;
use serde_json::Value;

/// Evaluate a JSONLogic rule against a data value.
///
/// No fuel limit. No custom operators. Returns the raw JSONLogic result value.
///
/// Use [`evaluate`](crate::evaluate) for FSM guard positions — it adds fuel
/// metering, typed errors, and custom operator support.
pub fn apply(rule: &Value, data: &Value) -> Result<Value, ApplyError> {
    let ctx = EvalCtx::new();
    let mut fuel = usize::MAX;
    eval::apply_value(rule, data, &ctx, &mut fuel)
}