gen_swift |
|
|
mod.rs |
# Swift bindings backend for UniFFI
This module generates Swift bindings from a [`crate::ComponentInterface`] definition,
using Swift's builtin support for loading C header files.
Conceptually, the generated bindings are split into two Swift modules, one for the low-level
C FFI layer and one for the higher-level Swift bindings. For a UniFFI component named "example"
we generate:
* A C header file `exampleFFI.h` declaring the low-level structs and functions for calling
into Rust, along with a corresponding `exampleFFI.modulemap` to expose them to Swift.
* A Swift source file `example.swift` that imports the `exampleFFI` module and wraps it
to provide the higher-level Swift API.
Most of the concepts in a [`crate::ComponentInterface`] have an obvious counterpart in Swift,
with the details documented in inline comments where appropriate.
To handle lifting/lowering/serializing types across the FFI boundary, the Swift code
defines a `protocol ViaFfi` that is analogous to the `uniffi::ViaFfi` Rust trait.
Each type that can traverse the FFI conforms to the `ViaFfi` protocol, which specifies:
* The corresponding low-level type.
* How to lift from and lower into into that type.
* How to read from and write into a byte buffer.
|
8018 |
templates |
|
|
test.rs |
|
7092 |