alef 0.69.0

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        {{ code }} => {
            let msg = if custom_ptr.is_null() {
                String::new()
            } else {
                // SAFETY: caller guarantees custom_ptr is readable for custom_len bytes.
                let bytes = unsafe { std::slice::from_raw_parts(custom_ptr.cast::<u8>(), custom_len) };
                let value = String::from_utf8_lossy(bytes).into_owned();
                if let Some(free) = free_string {
                    // SAFETY: free is the allocator-matched destructor supplied with the callback table.
                    unsafe { free(custom_ptr) };
                }
                value
            };
            VisitorResult::{{ variant_name }}(msg)
        },