I have an example repo of a bloom filter to learn about FFI. There I compare FFI gem, to C-extension, to pure ruby.
In writing the FFI version your docs were invaluable.
I have suggested improvements for ruby:
ffi_lib can fail to load the library on macos as there seem to be some issues with setting the LD_LIBRARY_PATH when using rake and rspec. I worked around this by telling the FFI gem to search via normal means, but fallback to looking at Ruby's load path if that does not work. I am looking into it, but can't seem to find any existing docs on this behavior.
Instead of exposing the auto-pointer class, create a pointer wrapper class so that the class is fully ruby-like to users (no need to expose the binding module. Also, by attaching the functions to the enclosing module callers can use an object-based API or a c-style api under the same namespace.
Only 1 for rust:
Using optionals for any of the method-like functions works really well compared to checking for null pointers and mapping the raw pointer to a reference ourselves.
I have an example repo of a bloom filter to learn about FFI. There I compare FFI gem, to C-extension, to pure ruby. In writing the FFI version your docs were invaluable.
I have suggested improvements for ruby:
See https://github.com/misalcedo/bloom/blob/master/lib/bloom_ffi.rb
Only 1 for rust: Using optionals for any of the method-like functions works really well compared to checking for null pointers and mapping the raw pointer to a reference ourselves.
See https://github.com/misalcedo/bloom/blob/master/src/lib.rs