pub unsafe fn return_success(
data: Value,
result_buf: *mut *mut u8,
result_len: *mut usize,
) -> i32Expand description
Return a success result to the framework
This handles all the unsafe memory management details:
- Converts the value to JSON
- Allocates a buffer
- Shrinks to minimize memory usage
- Returns the pointer and capacity to the framework
§Safety
The caller must ensure that:
result_bufpoints to valid, properly aligned memory for writing a pointerresult_lenpoints to valid, properly aligned memory for writing a usize- These pointers remain valid for the duration of the call
- The pointers are not aliased (no other mutable references exist)
§Example
ⓘ
unsafe {
let result = json!({"status": "ok"});
return return_success(result, result_buf, result_len);
}