alef 0.60.0

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    match result {
        Ok(val) => {
            // Convert via Vec<u8> so the path works for both Vec<u8> and bytes::Bytes
            // (and any other type that implements Into<Vec<u8>>).
            let buffer = Vec::<u8>::from(val).into_boxed_slice();
            let len = buffer.len();
            let ptr = Box::into_raw(buffer).cast::<u8>();
            // SAFETY: out_ptr/out_len/out_cap were null-checked above.
            unsafe { *out_ptr = ptr; *out_len = len; *out_cap = len; }
            0
        }
        Err(e) => {
            set_last_error(2, &e.to_string());
            // SAFETY: out_ptr/out_len/out_cap were null-checked above.
            unsafe { *out_ptr = std::ptr::null_mut(); *out_len = 0; *out_cap = 0; }
            -1
        }
    }