Skip to main content

net_predicate_evaluate

Function net_predicate_evaluate 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn net_predicate_evaluate( predicate_json: *const c_char, tags_json: *const c_char, metadata_json: *const c_char, ) -> c_int
Expand description

Evaluate a wire-format Predicate against a (tags, metadata) context. Mirrors Predicate::evaluate_unplanned(ctx) from the substrate.

All three inputs MUST be NUL-terminated UTF-8 JSON strings.

Return values:

  • 1 — predicate evaluated to true.
  • 0 — predicate evaluated to false.
  • NetError::NullPointer (negative) — any of the three pointers is NULL.
  • NetError::InvalidUtf8 (negative) — input bytes aren’t valid UTF-8.
  • NetError::InvalidJson (negative) — failed to parse the predicate_json as a PredicateWire, the tags_json as a Vec<String>, the metadata_json as an object, OR any tag string failed to parse.

Stateless. Thread-safe. The substrate’s evaluator visits the predicate AST in declaration order without planner reordering; boolean results are invariant under planning, so callers that want planned evaluation can call this and trust the answer.

§Safety

predicate_json, tags_json, and metadata_json MUST point at NUL-terminated UTF-8 strings valid for the duration of the call. The buffers are not retained after return.