A Simple Rust Library
Exporting Rust functions and types to C is easy. Here’s a simple Rust library:
interoperability/rust/libanalyze/analyze.rs
interoperability/rust/libanalyze/Android.bp
rust_ffi {
name: "libanalyze_ffi",
crate_name: "analyze_ffi",
srcs: ["analyze.rs"],
include_dirs: ["."],
}
Speaker Notes
#[unsafe(no_mangle)]
disables Rust’s usual name mangling, so the exported
symbol will just be the name of the function. You can also use
#[unsafe(export_name = "some_name")]
to specify whatever name you want.