Expand description
§Runtime support code for uniffi
This crate provides the small amount of runtime code that is required by the generated uniffi component scaffolding in order to transfer data back and forth across the C-style FFI layer, as well as some utilities for testing the generated bindings.
The key concept here is the FfiConverter
trait, which is responsible for converting between
a Rust type and a low-level C-style type that can be passed across the FFI:
- How to represent values of the Rust type in the low-level C-style type system of the FFI layer.
- How to “lower” values of the Rust type into an appropriate low-level FFI value.
- How to “lift” low-level FFI values back into values of the Rust type.
- How to write values of the Rust type into a buffer, for cases where they are part of a compound data structure that is serialized for transfer.
- How to read values of the Rust type from buffer, for cases where they are received as part of a compound data structure that was serialized for transfer.
- How to return values of the Rust type from scaffolding functions.
This logic encapsulates the Rust-side handling of data transfer. Each foreign-language binding must also implement a matching set of data-handling rules for each data type.
In addition to the core FfiConverter
trait, we provide a handful of struct definitions useful
for passing core rust types over the FFI, such as RustBuffer
.
Re-exports§
Modules§
- deps
- ffi
- Types that can cross the FFI boundary.
- metadata
- Pack UniFFI interface metadata into byte arrays
Macros§
- assert_
compatible_ version - Assert that the uniffi runtime version matches an expected value.
- derive_
ffi_ traits - Derive FFI traits
- ffi_
converter_ rust_ buffer_ lift_ and_ lower - Macro to implement lowering/lifting using a
RustBuffer
- trace
Traits§
- Convert
Error - FfiConverter
- Generalized FFI conversions
- FfiConverter
Arc - FfiConverter for Arc-types
- Handle
Alloc - Manage handles for
Arc<Self>
instances - Lift
- Lift values passed by the foreign code over the FFI into Rust values
- LiftRef
- Lift references
- Lift
Return - Return foreign values to Rust
- Lower
- Lower Rust values to pass them to the foreign code
- Lower
Error - Return Rust error values
- Lower
Return - Return Rust values to the foreign code
- TypeId
- Type ID metadata
Functions§
- check_
compatible_ version - Check whether the uniffi runtime version is compatible a given uniffi_bindgen version.
- check_
remaining - A helper function to ensure we don’t read past the end of a buffer.
Type Aliases§
- Result
Result<T, Error>