[−][src]Crate ocaml
ocaml-rs is a library for directly interacting with the C OCaml runtime, in Rust.
Note: ocaml-rs is still experimental, please report any issues on github
This crate will allow you to write OCaml C stubs directly in Rust. It is suggested to build a static library to link to when compiling your OCaml code.
The following in Rust:
caml!(ml_add_10, |arg|, <result>, {
let n = arg.i32_val();
result = Value::i32(n + 10)
} -> result);
is equivalent to:
value ml_add_10(value arg) {
CAMLparam1(arg);
CAMLlocal(result);
int n = int_val(arg);
result = val_int(arg + 10)
CAMLreturn(result);
}
using the traditional C bindings.
For a more complete example see: https://github.com/zshipko/ocaml-vec
Re-exports
pub use runtime::*; |
pub use value::FromValue; |
pub use value::ToValue; |
pub use value::Value; |
Modules
| conv | |
| core | |
| runtime | |
| value |
Macros
| array | Create an OCaml array |
| caml | Defines an external Rust function for FFI use by an OCaml program, with automatic |
| caml_body | Defines an OCaml FFI body, including any locals, as well as a return if provided; it is up to you to define the parameters. |
| caml_ffi | |
| caml_local | Initializes and registers the given identifier(s) as a local value with the OCaml runtime. |
| caml_param | Registers OCaml parameters with the GC |
| list | Create an OCaml list |
| tuple | Create an OCaml tuple |
Structs
| Array | OCaml Array type |
| Array1 | OCaml Bigarray.Array1 type |
| List | OCaml list type |
| Str | OCaml String type |
| Tuple | OCaml Tuple type |
Enums
| Error | Error returned by |
| Tag | Tags are used to determine the type of value that is stored in an OCaml value |
Functions
| named_value | Returns a named value registered by OCaml |