Skip to main content

net_predicate_aggregate_debug_report

Function net_predicate_aggregate_debug_report 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn net_predicate_aggregate_debug_report( predicate_json: *const c_char, contexts_json: *const c_char, out_report_json: *mut *mut c_char, out_report_len: *mut usize, ) -> c_int
Expand description

Run predicate against every entry in contexts_json and write a PredicateDebugReport to the out-param. Mirrors PredicateDebugReport::from_evaluations(pred, contexts).

Inputs (NUL-terminated UTF-8 JSON):

  • predicate_json โ€” wire-format PredicateWire.
  • contexts_json โ€” JSON array of evaluation contexts: [{"tags": [...], "metadata": {...}}, ...]. Each context contributes one corpus row.

Outputs:

  • out_report_json / out_report_len โ€” the report JSON. Free with net_free_string. Wire shape:
{
  "total_candidates": <usize>,
  "matched": <usize>,
  "clause_stats": [
    {"label": "<debug-label>", "evaluated": <usize>, "matched": <usize>},
    ...
  ]
}

clause_stats is sorted by label (the substrate uses BTreeMap, so iteration is in label order).

Returns 0 on success, NetError::* (negative) on parse / null-pointer failure.

ยงSafety

All input pointers MUST point at NUL-terminated UTF-8 strings. On success the caller owns the report buffer and frees it via net_free_string.