From 82c86437cbc2fa0251ff373c9dce1867b6be7a68 Mon Sep 17 00:00:00 2001 From: Anand Krishnamoorthi <35780660+anakrish@users.noreply.github.com> Date: Thu, 11 Apr 2024 06:38:45 -0700 Subject: [PATCH] Add a note in example to prefer eval_rule over eval_query (#204) Signed-off-by: Anand Krishnamoorthi --- examples/regorus.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/regorus.rs b/examples/regorus.rs index f805c17..22118da 100644 --- a/examples/regorus.rs +++ b/examples/regorus.rs @@ -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)?);