alef 0.25.39

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{% if source_cfg -%}
#[cfg({{ source_cfg }})]
{% endif -%}
/// Get the `{{ field_name }}` field from a `{{ type_name }}`.
/// # Safety
/// Pointer must be a valid handle returned by this library.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn {{ prefix }}_{{ type_snake }}_{{ field_name }}({% if needs_len_out %}ptr: *const {{ qualified }}, out_len: *mut usize{% else %}ptr: *const {{ qualified }}{% endif %}) -> {{ ret_type }} {
    if ptr.is_null() {
        return {{ null_return_value }};
    }
    // SAFETY: null check above guarantees ptr is a valid pointer.
    let obj = unsafe { &*ptr };
{{ body }}
}