Navigating the code
The code for UniFFI is organized into the following crates:
./uniffi_bindgen
: This is the source for theuniffi-bindgen
executable and is where most of the logic for the UniFFI tool lives. Its contents include:./uniffi_bindgen/src/interface/
: The logic for parsing.udl
files into an in-memory representation calledComponentInterface
, from which we can generate code for different languages../uniffi_bindgen/src/scaffolding
: This module turns aComponentInterface
into Rust scaffolding, the code that wraps the user-provided Rust code and exposes it via a C-compatible FFI layer../uniffi_bindgen/src/bindings/
: This module turns aComponentInterface
into foreign-language bindings, the code that can load the FFI layer exposed by the scaffolding and expose it as a higher-level API in a target language. There is a sub-module for each supported language.
./uniffi
: This is a run-time support crate that is used by the generated Rust scaffolding. It controls how values of various types are passed back-and-forth over the FFI layer, by means of theFfiConverter
trait../uniffi_build
: This is a small hook to rununiffi-bindgen
from thebuild.rs
script of a UniFFI component, in order to automatically generate the Rust scaffolding as part of its build process../uniffi_macros
: This contains some helper macros that UniFFI components can use to simplify loading the generated scaffolding, and executing foreign-language tests../examples
: This contains code examples that you can use to explore the code generation process.