| Crates.io | modu_ffi |
| lib.rs | modu_ffi |
| version | 1.0.2 |
| created_at | 2026-01-25 09:30:30.853289+00 |
| updated_at | 2026-01-25 12:37:45.867638+00 |
| description | FFI library for modu |
| homepage | |
| repository | |
| max_upload_size | |
| id | 2068438 |
| size | 3,226 |
Makes implementing ffi functions for modu way easier
In rust:
use modu_ffi::*;
#[unsafe(no_mangle)]
pub extern "C" fn add(
argc: std::ffi::c_int,
argv: *const FFIValue
) -> FFIValue {
if argc != 2 {
panic!("add requires 2 arguments");
}
unsafe {
let a = (*argv.offset(0 as isize)).value.integer;
let b = (*argv.offset(1 as isize)).value.integer;
FFIValue::integer(a + b)
}
}
In modu:
import "ffi" as ffi;
let lib = ffi.load("./library_path.so"); // or .dll or .dylib
print(lib.add(1, 2));