The code for UniFFI is organized into the following crates:
./uniffi_bindgen: This is the source for the
uniffi-bindgenexecutable and is where most of the logic for the UniFFI tool lives. Its contents include:
./uniffi_bindgen/src/interface/: The logic for parsing
.udlfiles into an in-memory representation called
ComponentInterface, from which we can generate code for different languages.
./uniffi_bindgen/src/scaffolding: This module turns a
ComponentInterfaceinto 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 a
ComponentInterfaceinto 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 the
./uniffi_build: This is a small hook to run
build.rsscript 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.