Skip to main content

pamoja_rule_evaluator_evaluate

Function pamoja_rule_evaluator_evaluate 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_rule_evaluator_evaluate( rules: *mut PamojaRuleEvaluator, topic: *const c_char, reading: f32, ) -> *mut PamojaString
Expand description

Judges one reading from one topic against every rule that watches it.

§Arguments

  • rules - the evaluator.
  • topic - the topic the reading arrived on, as null-terminated UTF-8.
  • reading - the reading, already decoded from the message.

§Returns

The JSON array of what fired, in the order the rules are listed, which is [] when no rule watches the topic or the reading changed nothing. The caller releases it with pamoja_string_free. Null if a pointer is null, or if a rule watches the topic and the reading is not a finite number, with the reason available from pamoja_last_error_message.

§Safety

rules must be a live handle from pamoja_rule_evaluator_from_json, or null, and topic must be a valid null-terminated UTF-8 string for the duration of the call, or null.