How mozilla/uniffi-rs works
Main Components Identification
The system should be divided into these major components:
a) Core Components:
• uniffi_core: The fundamental runtime library
• uniffi_bindgen: The binding generator engine
• uniffi_macros: Procedural macros for interface definition
• uniffi_build: Build system integration
• uniffi_meta: Metadata handling system
• uniffi_udl: UDL (UniFFI Definition Language) parser
b) Foreign Language Bindings:
• Kotlin bindings generator
• Swift bindings generator
• Python bindings generator
• Ruby bindings generator
Top Level (Interface Layer):
• [UDL Files] ←→ [Proc Macros]
• ↓
Middle Level (Processing Layer):
• [uniffi_bindgen]
• ↓
• [Code Generation Engine]
• ↓
Bottom Level (Output Layer):
• [Kotlin] [Swift] [Python] [Ruby]
Component Relationships
a) Input Flow:
• How UDL files and Proc Macros feed into the uniffi_bindgen
• Uniffi_meta for metadata processing
• Link uniffi_udl for parsing UDL files
b) Processing Flow:
• Uniffi_bindgen to the template system
• Interaction with uniffi_core for runtime support
• Link to uniffi_build for compilation integration
c) Output Flow:
• Generation of language-specific bindings
• FFI layer creation
• Final library packaging
Special Elements
• Template system (showing how it feeds into each language generator)
• FFI layer (showing how it bridges Rust and target languages)
• Build pipeline integration points
• Testing infrastructure
Key Features to Highlight
• Thread safety handling
• Memory management
• Type conversion system
• Error handling
• Async/Future support
• Custom type support