flapigen
Tool for connecting programs or libraries written in Rust with other languages.
Foreign language api generator - flapigen. Former name rust_swig was changed to not confuse
with swig.
Currently implemented support for C++
and Java
, but you can write support
for any language of your choice. For an instruction how to integrate flapigen with your
project look here.
Suppose you have the following Rust code:
and you want to write in Java something like this:
Foo foo ;
int res ;
;
or in C++ something like this:
Foo ;
int res = foo.;
;
In order to implement it flapigen suggests the following functionality, in Rust project you write (in Rust language):
foreign_class!;
and that's all, as a result flapigen generates JNI wrappers for Rust functions and Java code to call these JNI functions or generates C compatible wrappers in case of C++ and C++ code to call these C functions.
If you want the interface file (the file containing foreign_class!
and so on)
to be automatically generated for you, checkout rifgen.