deno_plugin_ffi (WIP & Need Help)
Deno Foreign Function Interface.
deno_ffi is a Deno plugin for loading and calling dynamic libraries using pure JavaScript/TypeScript. It can be used to create bindings to native libraries without writing any Rust code.
It also simplifies the augmentation of Deno with Rust/C/C++ code as it takes care of handling the translation of types across JavaScript/TypeScript and C/Rust, which can add reams of boilerplate code to your otherwise simple C/Rust. See the example/
for an example of this use case.
Example
import * as ffi from "https://deno.land/x/ffi/mod.ts";
const libm = ffi.Library('libm', {
'add': [ 'int', [ 'int', 'int' ] ]
});
libm.add(1, 2); // 3
// You can also access just functions in the current process by passing a null
var current = ffi.Library(null, {
'btoa': [ 'string', [ 'string' ] ]
});
current.btoa('1234'); // MTIzNA==
License
deno_plugin_ffi is released under the MIT License. See the bundled LICENSE file for details.