Navigating the code
The code for UniFFI is organized into the following crates:
-
./uniffi(docs.rs, source): The main entry-point to UniFFI - almost all consumers should be able to use facilities expored by this module. -
./uniffi_bindgen(docs.rs, source): The the source for theuniffi-bindgenexecutable and is where most of the logic for the foreign bindings generation lives. Its contents include:./uniffi_bindgen/src/interface/: Convertinguniffi_metatypes into an in-memory representation calledComponentInterface, from which we can generate code for different languages../uniffi_bindgen/src/scaffolding: This module generates.rsfiles for the parts of theComponentInterfacedefined in UDL./uniffi_bindgen/src/bindings/: This module turns aComponentInterfaceinto foreign-language bindings, the code that can load the FFI layer exposed by Rust and expose it as a higher-level API in a target language. There is a sub-module for each internally supported language.
-
./uniffi_meta(docs.rs, source): The types used to represent the metadata used to describe theComponentInterfaceused to generate the Rust scaffolding and the foreign bindings. -
./uniffi_udl(docs.rs, source) : The parsing of UDL files, turning them intouniffi_metatypes. -
./uniffi_build(docs.rs, source): A small hook to rununiffi-bindgenfrom thebuild.rsscript of a UniFFI component, in order to automatically generate the Rust scaffolding as part of its build process. -
./uniffi_macros(docs.rs, source): Contains the proc_macro support, which does much of the heavy-lifting for defining the Rust FFI. -
./examples: Contains code examples demonstrating the capabilites and code generation process. -
./fixtures: Our test suite.