Add a note in example to prefer eval_rule over eval_query (#204)

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-04-11 06:38:45 -07:00
committed by GitHub
parent 05e91da06e
commit 82c86437cb

View File

@@ -70,7 +70,14 @@ fn rego_eval(
engine.set_input(input);
}
// Evaluate query.
// Note: The `eval_query` function is used below since it produces output
// in the same format as OPA. It also allows evaluating arbitrary statements
// as queries.
//
// Most applications will want to use `eval_rule` instead.
// It is faster since it does not have to parse the query string.
// It also returns the value of the rule directly and thus is easier
// to use.
let results = engine.eval_query(query, enable_tracing)?;
println!("{}", serde_json::to_string_pretty(&results)?);