alef 0.23.35

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/// Run the service entrypoint '{{ method_name }}'.
///
/// # Safety
/// - `owner` must be a valid pointer returned by `{{ new_fn_name }}()` and not yet freed.
/// - `owner` is consumed by this call; it must not be used or freed afterwards.
#[no_mangle]
pub extern "C" fn {{ fn_name }}(
    owner: *mut {{ opaque_name }}{{ param_decls }}
) -> {{ return_type }} {
    if owner.is_null() {
        return {{ null_return }};
    }
{{ pre_call_body }}    // SAFETY: owner was allocated by _new() (Box::into_raw) and is consumed here.
    let owner = unsafe { Box::from_raw(owner) };
    let inner = *owner.inner;
{{ runtime_block }}{{ return_body }}}