cffi + rust

Difference between version 0 and 2 - Previous - Next
Basic example to call a rust function with the helps of [CFFI Package].

rust2cffi.rs :

======
// Specifies the type of crate.
#![crate_type = "dylib"]
// Specifies the crate name.
#![crate_name = "rust2cffi"]
// Disables symbol name encoding.
#[no_mangle]
// compile: rustc rust2cffi.rs
pub extern fn mul(value1: i32, value2: i32) -> i32 {
    value1 * value2
}
======
rust2cffi.tcl

======
package require cffi

cffi::Wrapper create RUST2CFFI librust2cffi[info sharedlibextension]
# call rust function...RUST2CFFI function mul int {nvalume1 int nvalume2 int}

puts [mul 3 3]

======