alef 0.25.39

Opinionated polyglot binding generator for Rust libraries
Documentation
/// Configure the service via '{{ method_name }}'.
///
/// # Safety
/// - `owner` must be a valid pointer returned by `{{ new_fn_name }}()` and not yet freed.
/// - The same `owner` pointer is returned on success — the caller does **not**
///   need to swap the handle they hold. Returns `null` on failure (the original
///   handle is still valid in that case but should be inspected for usability).
#[no_mangle]
pub extern "C" fn {{ fn_name }}(
    owner: *mut {{ opaque_name }}{{ param_decls }}
) -> *mut {{ opaque_name }} {
    if owner.is_null() {
        return std::ptr::null_mut();
    }
{{ pre_call_body }}    // SAFETY: owner was allocated by _new() and is valid until freed.
    // Take the inner box out, transform it, and put the result back. The opaque
    // shell stays at the same address so the caller's handle remains valid.
    unsafe {
        let inner = match (*owner).inner.take() {
            Some(boxed) => *boxed,
            None => return std::ptr::null_mut(),
        };
        (*owner).inner = Some(Box::new(inner.{{ method_name }}({{ call_args }})));
    }
    owner
}