rust_interface_file_generator

Crates.iorust_interface_file_generator
lib.rsrust_interface_file_generator
version0.2.5
sourcesrc
created_at2021-09-18 19:24:30.011268
updated_at2021-10-07 00:01:54.547255
descriptionffi Interface file generator. Use with flapigen
homepage
repositoryhttps://github.com/Kofituo/rust_interface_file_generator
max_upload_size
id453398
size70,084
Kofi Otuo (Kofituo)

documentation

README

rust_interface_file_generator

Rust IntelliJ IDEA Rust Documentation

Program for translating libraries written in Rust to interface files.

Note that this crate is deprecated. Use rifgen

It works with flapigen. For instructions on how to integrate with your project, click here

Suppose you have the following Rust code:

struct Foo {
    data: i32
}

impl Foo {
    fn new(val: i32) -> Foo {
        Foo{data: val}
    }

    fn f(&self, a: i32, b: i32) -> i32 {
        self.data + a + b
    }

    fn set_field(&mut self, v: i32) {
        self.data = v;
    }
}

Using flapigen, you'd have to write an interface file similar to

foreign_class!(class Foo {
    self_type Foo;
    constructor Foo::new(_: i32) -> Foo;
    fn Foo::set_field(&mut self, _: i32);
    fn Foo::f(&self, _: i32, _: i32) -> i32;
});

in order to write in Java something like this:

Foo foo = new Foo(5);
int res = foo.f(1, 2);
assert res == 8;

or in C++ something like this:

Foo foo(5);
int res = foo.f(1, 2);
assert(res == 8);

This program generates the interface file, so you can focus more time on your code

Other Features:

✅ Fast and easy to use

✅ Specify style of the resulting code i.e. Whether CamelCase or snake_case

✅ Works, with structs, enums, trait

✅ You don't have to worry about the "order" in which code in the interface has to be

Users Guide

Read the rust_interface_file_gen users guide here!

View on crates.io

##Update to rifgen

This crate has now been migrated to rifgen

Commit count: 98

cargo fmt