Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/m4b/raml
OCaml runtime and FFI bindings directly in Rust
https://github.com/m4b/raml
ffi-bindings ocaml rust
Last synced: 3 months ago
JSON representation
OCaml runtime and FFI bindings directly in Rust
- Host: GitHub
- URL: https://github.com/m4b/raml
- Owner: m4b
- Created: 2017-05-19T04:51:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-19T06:51:20.000Z (over 7 years ago)
- Last Synced: 2024-09-29T06:41:09.666Z (3 months ago)
- Topics: ffi-bindings, ocaml, rust
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 78
- Watchers: 8
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![goats are actually the best animal ever invented](https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Hausziege_04.jpg/480px-Hausziege_04.jpg)
# Raml - Intelligent OCaml FFI in Rust
Direct OCaml bindings without ever leaving Rust - no C stubs!
(you still have to know how the C ffi bindings work; if you do, the macros are almost identical to the C ones in their naming and purpose)
Please see the example in `examples` for the Rust code in `rust` for the Rust code that OCaml code will call and the `ocaml` directory for the OCaml code that calls the Rust code.
Also, please bear with me as I'm trying to add more documentation and examples, but I am very busy; if you see something, don't hesitate to add a PR or issue, thanks :)
A basic example demonstrates their usage:
```rust
caml!(ml_beef, |parameter|, , {
let i = int_val!(parameter);
let res = 0xbeef * i;
println!("about to return 0x{:x} to OCaml runtime", res);
local = val_int!(res);
} -> local);
```The macro takes care of _automatically_ declaring `CAMLparam` et. al, as well as `CAMLlocal` and `CAMLreturn`.
If you need more fine grained control, `caml_body!` and others are available.
### Documentation
https://docs.rs/raml/
### Usage
raml should work with a recent `rustc` (I test on 1.16), and _does not require nightly_.
Add to your `Cargo.toml`
```toml
[dependencies]
raml = "0.1.0"
```