Skip to main content

copperlace_ruleset_render_structured_json_with_context

Function copperlace_ruleset_render_structured_json_with_context 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn copperlace_ruleset_render_structured_json_with_context( handle: *const CopperlaceRuleSet, rule: *const c_char, context_keys: *const *const c_char, context_values: *const *const c_char, context_len: usize, format_json: bool, out_json: *mut *mut c_char, out_error: *mut *mut c_char, ) -> c_int
Expand description

Renders a named structured rule from a ruleset handle with initial context.

context_keys and context_values are parallel arrays of UTF-8 C strings. They may be null only when context_len is zero. Duplicate keys are allowed; later entries replace earlier entries.

On success, writes an owned UTF-8 JSON string to out_json and returns COPPERLACE_OK. When format_json is false, the JSON is compact. When true, it is formatted with tab indentation. On failure, writes null to out_json, writes an owned error string to out_error when provided, and returns a nonzero status code. Returned output and error strings must be released with copperlace_string_free.

ยงSafety

handle must be a live ruleset handle returned by Copperlace. rule must point to a valid NUL-terminated UTF-8 string. When context_len is nonzero, context_keys and context_values must each point to arrays with at least context_len entries, and every entry must point to a valid NUL-terminated UTF-8 string. out_json must be a valid writable pointer. out_error must be valid for writing when non-null. Any returned output or error string must be released with copperlace_string_free.