{% 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 }}
}
