Ocaml rust ffi bindings


#1

Hello, I wrote up some OCaml FFI bindings a long while back and figured I should get around to pushing them.

They’re pretty basic, but what’s interesting is they allow direct binding into OCaml via rust, which typically requires so-called “C stubs” or a C bridge. I’ve gotten an OCaml binary calling into Rust, and also a rust binary registering OCaml callbacks and calling those.

The bindings are definitely incomplete, probably unsafe, and much room for improvement or other cool ideas (like automatic conversion to rust string from an OCaml string, etc.), but its a fun start.

I think one of the interesting things is the macro takes care of some of the tedious bookeeping details when writing OCaml C bindings, like taking care of CAMLparam and CAMLlocal and CAMLreturn for you. This won’t really make sense unless you’re familiar with OCaml C FFI stubs.

Anyway:

  1. repo: https://github.com/m4b/raml
  2. docs: https://docs.rs/raml

Cheers!


#2

As someone who just started learning Rust and OCaml, this is really exciting! Thanks


#3

No problem!

If you have any questions or find a bug, don’t hestitate to file an issue :slight_smile: