uniffi
a multi-language bindings generator for rust
0.32.0
11M downloads/mo
#2942 most downloaded on crates.io
mozilla/uniffi-rs
What this package is like to depend on
Last release 1 months ago
30 Jun 2026
Ships fairly regularly
a new release about every 2 months
Most releases are documented
notes for 52 of 64 stable releases
2 versions withdrawn
withdrawn after publishing
6 years old
66 releases · first in 2020
6 releases in the last 12 months
see the full history below
Release timeline
66 releases · Sep 2020 to Jun 2026Releases
latest 60 of 66-
0.32.030 Jun 2026Release notes
Open source →⚠️ Breaking Changes ⚠️
- Kotlin and Python now fail to generate bindings when there are async primary constructors. Previously these languages skipped the constructor in this case or generated a constructor that always threw. You can get similar behavior by adding the primary constructor to the uniffi.toml excludes list in uniffi.toml (e.g. `excludes = ["MyObject.new"])
- Ruby: Force named parameters for enum constructors (#2880)
- The
--configflag now expects a global config file rather than a flatuniffi.toml-style override. Old-style files will produce a warning and be ignored. See #2866 [ByRef] bytesUDL arguments now map to&[u8]on the Rust side instead of&Vec<u8>. UDL-defined functions whose Rust implementations take&Vec<u8>must change to&[u8]. Proc-macro signatures (fn foo(x: &[u8])) are unchanged. On the Kotlin side, call sites must now pass a directjava.nio.ByteBufferrather thanByteArray; migrate withByteBuffer.allocateDirect(arr.size).put(arr).flip(). Swift (Data) and Python (bytes) call sites are unchanged. (#2878)- Reworked the experimental pipeline bindgen code. Any external binding generators using this will need to be reworked as well. See #2787 for examples of how this can be done.
⚠️ Breaking Changes for external bindings authors ⚠️
- The signature for
CrateConfigSupplier::from_cargo_metadata_commandhas changed. It now inputs aMetadataCommandinstance and aCargoMetadataOptionsrather than just ano_depsflag.
What's Fixed
- Fixed bug that sometimes prevented renaming items inside a submodule #2792
- Exempted
UniFfiTagfromclippy::exhaustive_structssince downstream projects may depend on it #2809 - Fixed compile errors when exporting ambiguous method names #2937
- Ruby: Code for all kinds of enums and custom types is now correctly generated #2880 and #2891
⚠️ Breaking Changes for external bindings authors ⚠️
- There's a new
GlobalConfigstruct for managing config. It replacesBindgenPathsLayer::get_config()method which has been removed. See #2866. [ByRef] bytesarguments now travel across the FFI as aForeignBytes(pointer + length) value rather than aRustBuffer. External bindings need to accept the foreign-language byte buffer at the call site and lower it toForeignBytesfor the duration of the call (no copy). (#2878)
What's New?
-
Global config file support via
--config. See the docs. -
Traits can now be exported with
#[uniffi::export(foreign)]for foreign-only implementations, or#[uniffi::export(rust, foreign)]for both Rust and foreign implementations. Thewith_foreignflag is deprecated in favor ofrust, foreign. -
Recursive enums are now supported. UniFFI automatically detects when enum and record types participate in cycles — self-referential, mutually recursive, or cycling through a record — and generates appropriate bindings:
indirectin Swift, forward references in Python (#2834). -
Box<T>now automatically implements FFI traits whenTimplements them, allowing direct use in enum variants and function parameters without NewType wrappers (#2808) -
Record fields can now be renamed with the proc-macro
name = "new_field_name"attribute (#2794) -
Items can be excluded from the generated bindings using
uniffi.toml. -
Added
mutable_recordsconfiguration option to allow specific records to remain mutable even whengenerate_immutable_recordsis enabled (Kotlin and Swift). -
Kotlin objects now have an
uniffiIsDestroyedproperty that returnstrueif the Rust reference no longer exists (#2825) -
Updated
askamaversion to0.15.6 -
Custom Types can have docstrings in some languages (#2853)
-
Ruby: Expose standard Rust traits for generated ruby code (#2883)
-
Ruby: Add support for sync foreign traits (#2916)
-
Ruby: Add async support (#2923)
-
Added zero-copy transfer of
&[u8]/[ByRef] bytesarguments from foreign code to Rust. Kotlin (java.nio.ByteBuffer, must be direct), Swift (Data), and Python (bytes-like, buffer protocol) pass byte buffers as pointer + length (ForeignBytes) rather than copying throughRustBuffer. Not yet supported on Ruby, and not yet supported in async functions on any language (#2878). -
#[uniffi::export(async_runtime = "tokio")]can now be applied to trait exports, wrapping each method's FFI scaffolding future inasync_compat::Compatthe same way it does for inherent impls and free functions (#2899). -
Added support for using
HashSetwith proc-macros -
Allow literal number suffix with
derive(uniffi::Enum)(#2926)
-
0.31.217 Jun 2026Release notes
Open source →What's Fixed
- Kotlin: Fixed JNA direct-mapped
u8/u16return values by widening the internal return carrier toInt, which avoids signedness mismatches during checksum validation and other direct-return paths on Android ARM32. (#2897) - Kotlin: Fix async functions that return an external/RustBuffer type
- Swift: Fixed
FfiConverterStringsilently stripping a leading U+FEFF byte order mark from Rust strings. - Swift: Prevent strict concurrency warning with callback interface tables
- Kotlin: Fixed JNA direct-mapped
-
0.31.113 Apr 2026Release notes
Open source →What's Fixed
-
0.31.014 Jan 2026Release notes
Open source →⚠️ Breaking Changes ⚠️
- The
uniffi-bindgencommand no longer accepts the--lib-fileargument. Instead, pass the library directly without a UDL file. - Removed the
[Swift|Kotlin|Python|Ruby]BindingGeneratortypes. Useuniffi::generateinstead to generate these bindings.
What's Deprecated?
BindgenCrateConfigSupplier. Use the newBindgenPathstype instead.
What's New?
- Added the
uniffi::generatefunction. This implements theuniffi-bindgen generatecommand and allows it to be run programmatically. - The
--libraryargument ofuniffi-bindgenis deprecated and no longer has an effect.uniffi-bindgenwill now auto-detect when the source path is a library rather than a UDL file. - All builtin bindings support renaming almost all of the interface (types, args, items, variants, etc) via TOML definitions - see the docs. (#2715)
- Support for methods on records and enums (#2706, #2724, #2739).
- Added the
BindgenPathstype, which is the new way to find UDL and TOML data. - Enum variants can now be renamed with the proc-macro
name = "NewVariantName"attribute (#2783) - It's now possible to build a
uniffi-bindgenthat doesn't depend oncargo-metadata(#2746) - MSR is now 1.87, our CI runs against 1.90.
What's Fixed
- Kotlin: Rust enums with nested payload types are generated using the inner type’s fully qualified name, avoiding naming conflicts and allowing payloads to reuse the variant name (#2698).
- Kotlin: Enums and errors now support exporting trait methods (Display, Debug, Eq, Hash, Ord) via
toString(),equals(),hashCode(), andcompareTo()implementations. Flat enums only support exportingDisplay. (#2700). - Kotlin: Initialization functions now have a stable ordering (#2718)
- Prevented a potential segfault when completing foreign futures (#2733)
- Swift: exporting
Eq,Cmpetc would generate invalid code if the Rust name had unusual captialization (#2707). - Fix an issue when an impl block has only async constructors (#2778)
- Fix issues parsing some
#[doc(...)]attributes in exported blocks (#2777) - Fix extracting metadata from multi-arch binary files (#2750)
- Python: improve generated code for
__eq__(#2741)
⚠️ Breaking Changes ⚠️
- Method checksums no longer include the self type. This shouldn't affect normal use. However
checksum comparisons will fail if bindings built with
0.30.xand the Rust code is built with0.31.x, or vice-versa.
⚠️ Breaking Changes for external bindings authors ⚠️
- The
module_pathfield now stores full module paths rather than crate names only. External bindings authors will probably need to make some minor changes to work with this. See https://github.com/mozilla/uniffi-rs/pull/2695/ for examples.
- The
-
0.30.008 Oct 2025Release notes
Open source →⚠️ Breaking Changes ⚠️
- UDL-based trait interfaces must now be wrapped with the
#[uniffi::trait_interface]attribute. - Python: Trait interface implementations must now inherit from the trait base class.
This will look like
class PyTraitName(RustTraitName):
What's new?
- All user-defined types can now be renamed with the proc-macro
name = "NewName"attribute (like already supported for methods and constructors) (#2661) - Enums and Records support exporting uniffi traits (ie,
Display,Hash,Eqetc) (#2555) - Support for exporting the
Ordtrait, allowing objects to be ordered by Rust (#2583). #[uniffi(default)]literals are now optional - eg,#[uniffi(default)]and#[uniffi(default = 0)]are equivalent. Similarly for args;#[uniffi::export(default(arg_name))]. When no literal is specifed, named types (objects, records, etc) can be used as long as they have suitable default values. (#2543). Custom types too (#2603)- Custom
enumandobjecttypes can be used as error type (#2658) - Objects can implement external traits (#2430)
- Fix for external errors when error only used externally (#2641)
- Kotlin:
- Python:
- Improved how default values are handled in function signatures etc and more canonical use of Python dataclasses, all towards making mypy happier (#2552)
- Methods now have typing annotations for return values (#2625)
- Fix relative imports (#2657)
- Fix shadowing param names with internal variables in Python (#2628/#2645)
- Don't allow objects to be passed as arguments when traits are expected (#2649)
- Swift:
- All object protocol conformances are public (#2671)
- Initialization functions now have a stable ordering when using external types. This makes the generated source files deterministic.
⚠️ Breaking Changes for external bindings authors ⚠️
uniffi_bindgen::backendhas been removed.#[uniffi(default)]changes how defaults are represented.FfiType::RustArcPtrhas been removed and the FFI type for objects/interfaces is now au64. Bindings authors will need to update their code to reflect this:- Lowering/lifting now uses
u64values - The free function inputs a
u64handle rather than a raw pointer - The clone function inputs and returns a
u64handle rather than a raw pointer
- Lowering/lifting now uses
EnumsandRecordscan have methods, so theMethodnow carriesself_typeinstead of the object name. In the templates, forCallable.takes_self()is replaced withCallable.self_type().- Trait / Callback interface changes
- VTable fields are now:
free,clone, followed by a field for each interface method. Note Thatfreeis now at the start of the vtable rather than the end. - Trait interface changes:
- Foreign handles must always have the lowest bit set
- Both Rust and foreign handles can now be passed across the FFI. When Lifting/lowering trait interface handles, check if the handle was generated from Rust or the foreign side.
- See https://github.com/mozilla/uniffi-rs/pulls/2586 examples of how the builtin bindings here changed.
- VTable fields are now:
- UDL-based trait interfaces must now be wrapped with the
-
0.29.514 Nov 2025Nothing published for this version
-
0.29.424 Jul 2025Release notes
Open source →- Fixed a bug where objects with alignment >= 32 could be freed to early (https://github.com/mozilla/uniffi-rs/issues/2600)
-
0.29.306 Jun 2025Release notes
Open source →What's new?
- HashMaps in UDL now support a default value with an empty map (#2539).
-
0.29.205 May 2025Release notes
Open source →What's fixed?
-
Allow
uniffi_reexport_scaffolding!macro to work in Rust 2024 (#2476) -
Python: fix issues with unusual name capitalization, (#2464)
-
Swift bindings can now generate automatic conformance to the
CaseIterableprotocol for simple enums and errors usinggenerate_case_iterable_conformance = truein the configuration. -
Swift bindings can now generate automatic conformance to the
Codableprotocol for records, enums and errors usinggenerate_codable_conformance = truein the configuration. Be aware that serialization in Swift may lead to different and incompatible results compared to serialization in Rust.
⚠️ Breaking Changes for external bindings authors ⚠️
-
Some async-related names have changed. Bindings authors may need to update their code to reflect the new names. This is a name-change only -- the FFI and semantics are still the same.
UniffiForeignFutureFreeis nowUniffiForeignFutureDroppedCallbackUniffiForeignFutureisUniffiForeignFutureDroppedCallbackStruct.RustFuturePoll::MaybeReadyis nowRustFuturePoll::Wake.
-
-
0.29.118 Mar 2025Release notes
Open source →What's fixed?
-
Bindings support
liftandlowerfor CustomTypes in uniffi.toml to match the docs (#2438) -
Python: fix using Vecs and other composite types in tuple enums (#2445)
-
Kotlin: fix interfaces in sequences and records being not disposed (#2479)
What's changed?
-
Rust 2024 edition is supported, msrv is 1.82.0
-
The uniffi-bindgen CLI support no longer brings in the
clap/colorfeature, reducing dependencies (#2435) -
Protocols generated for Swift now conform to the
Sendableprotocol. This means that UniFFI traits will too, but it also means foreign implemented traits also must when Swift 6 conformance is enabled. See the Swift section of the manual for more. (#2450) -
You can now optionally specify extra frameworks like
CoreBluetoothorCoreFoundationwhen generating a modulemap file for an xcframework.
-
-
0.29.006 Feb 2025Release notes
Open source →⚠️ Breaking Changes ⚠️
We've made a number of breaking changes to fix long standing paper-cuts with UniFFI in multi-crate and procmacro+udl environments.
See the detailed upgrade notes
While no changes are required to foreign code, we apologize for the inconvenience!
You are impacted if you use
UniffiCustomTypeConverterto implement "Custom types", or use UDL with types from more than one crate.-
UniffiCustomTypeConverterhas been removed, you must now use thecustom_type!macro instead. -
The UDL syntax for external types has changed.
typedef extern MyEnum;has been replaced withtypedef enum MyEnum;.[Custom]and[External]are the only supported attributes for atypedef. -
"remote" types (where UDL can re-export a type defined in a non-UniFFI crate - eg,
log::Level) must now use a[Remote]attribute. -
Various
use_udl_*/use_remote_typeetc macros have been removed.
uniffi::generate_component_scaffoldinghas been removed. It's almost certainly unused as it is behind the wrong feature and undocumented.uniffi::generate_scaffoldingdoes exacly the same thing and is correctly behind thebuildfeature.
What's new?
-
Kotlin and Swift follow Python: Proc-macros exporting an
impl Trait for Structblock now has a class inheritance hierarcy to reflect that. #2297, #2363 -
External types work much better, particularly between UDL and proc-macros. (Kotlin external errors do not work - #2392).
-
Swift interfaces are marked as
Sendable(#2318) -
Removed the
logdependency and logging statements about FFI calls. These were not really useful to consumers and could have high overhead when lots of FFI calls are made. Instead, theffi-tracefeature can be used to get tracing-style printouts about the FFI. -
External errors work for Swift and Python. Kotlin does not work - see #2392.
-
Added
disable_java_cleaneroption for kotlin to allow for Java 8 compatible code -
Proc-macros now allow Enums to hold objects (#1372)
-
Swift and Kotlin make it possible to opt-out of the runtime checksum integrity tests done as the library is initialized. Opting out will shoot yourself in the foot if you mixup your build pipeline in any way, but might speed the initialization. (Python apparently hasn't made these checks for some time, so no changes there!)
What's changed?
-
Switching jinja template engine from askama to rinja.
-
For
wasm32build targets,Futures do not have to beSend(#2418), making them compatible withwasm-bindgenFutures.
⚠️ Breaking Changes for external bindings authors ⚠️
-
Added the
FfiType::MutReferencevariant. -
Callabletrait has changed,return_typeandthrows_typeare now references. -
Type::Externalhas been removed. Binding authors must now check the type is local themselves before deciding to treat it as a local or external type.To get a feel for the impact on the bindings, see where we first did this for custom types, and where we then stopped using it entirely
-
-
0.28.314 Nov 2024Release notes
Open source → -
0.28.208 Oct 2024Release notes
Open source →What's new?
-
Added the
uniffi-bindgen-swiftbinary. It works likeuniffi-bindgenbut with additional Swift-specific features. See https://mozilla.github.io/uniffi-rs/latest/swift/uniffi-bindgen-swift.html for details. -
Removed the old and outdated diplomat comparison doc
-
Proc-macros recognise when you are exporting an
impl Trait for Structblock. Python supports this by generating an inheritance hierarcy to reflect that. #2204
What's fixed?
uniffi.tomlof crates without alibtype where ignored in 0.28.1- Python: Fixed a bug when enum/error names were not proper camel case (HTMLError instead of HtmlError).
- Python: Fixed the class hierarcy generated for traits ((#2264)[https://github.com/mozilla/uniffi-rs/issues/2264])
-
-
0.28.113 Aug 2024Release notes
Open source →What's new?
- Lift errors will not cause an abort when
panic=abortis set. - Added the
cargo_metadatafeature, which is on by default. In some cases, this can be disabled for better compatibility with projects that don't use cargo. - A new bindgen command line option
--metadata-no-depsis available to avoid processing cargo_metadata for all dependencies. - In UDL it's now possible (and preferred) to remove the
[Rust=]attribute and use a plain-old typedef. See the manual page for this.
What's changed?
- Kotlin will use the more efficient Enum.entries property instead of Enum.values() when possible
- Lift errors will not cause an abort when
-
0.28.011 Jun 2024Release notes
Open source →What's new?
-
Objects error types can now be as
Result<>error type without wrapping them inArc<>. -
Swift errors now provide
localizedDescription(#2116) -
Procmacros support tuple-errors (ie, enums used as errors can be tuple-enums.)
What's fixed?
-
Fixed a problem with procmacro defined errors when the error was not used as an
Errresult in the namespace (#2108) -
Custom Type names are now treated as type names by all bindings. This means if they will work if they happen to be keywords in the language. There's a very small risk of this being a breaking change if you used a type name which did not already start with a capital letter, but this changes makes all type naming consistent. (#2073)
-
Macros
uniffi::methodanduniffi::constructorcan now be used withcfg_attr. (#2113) -
Python: Fix custom types generating invalid code when there are forward references. (#2067)
What's changed?
-
The internal bindings generation has changed to make it friendlier for external language bindings. However, this a breaking change for these bindings. No consumers of any languages are impacted, only the maintainers of these language bindings. (#2066), (#2094)
-
The async runtime can be specified for constructors/methods, this will override the runtime specified at the impl block level.
-
-
0.27.303 Jun 2024Release notes
Open source →- Removed dependencies on
unicode-linebreakandunicode-width. They were being pulled in a sub-dependencies for thetextwrapcrate, but weren't really useful.
- Removed dependencies on
-
0.27.215 May 2024Release notes
Open source →What's new?
- Added the
scaffolding-ffi-buffer-fnsfeature. When enabled, UniFFI will generate an alternate FFI layer that can simplify the foreign bindings code. It's currently being tested out for the gecko-js external binding, but other external bindings may also find it useful.
What's changed?
- Removed the dependency on the `oneshot' crate (https://github.com/mozilla/uniffi-rs/issues/1736)
- Added the
-
0.27.103 Apr 2024Release notes
Open source →What's fixed?
-
Fixed a regression in 0.27.0 which broke throwing constructors (#2061).
-
Fixed a RustBuffer memory leak (#2056)
-
-
0.27.026 Mar 2024Release notes
Open source →What's new?
-
Constructors can be async. Alternate constructors work in Python, Kotlin and Swift; only Swift supports primary constructors.
-
Enums created with proc macros can now produce literals for variants in Kotlin and Swift. See the section on enum proc-macros for more information.
-
Objects can be errors - anywhere you can specify an enum error object you can specify an
Arc<Object>- see the manual. -
Functions, methods and constructors exported by procmacros can be renamed for the forgeign bindings. See the procmaco manual section.
-
Trait interfaces can now have async functions, both Rust and foreign-implemented. See the futures manual section for details.
-
Procmacros support tuple-enums.
-
RustBufferwas changed to useu64fields. This eliminates panics when the capacity of the vec exceedsi32::MAX. This can happen with the current Vec implementation when String/Vec sizes approachi32::MAXbut don't exceed it. -
Proc-macro function/method arguments can now have defaults
-
Proc-macro record defaults now support empty vecs and Some values.
-
Swift: Records and Enums without object references can now be made
SendableSwift, by opting in to new Configurationexperimental_sendable_value_typesinuniffi.toml.
What's fixed?
- Fixed a memory leak in callback interface handling.
⚠️ Breaking Changes ⚠️
- Python: Force named parameters for struct constructors (#1840)
- Ruby: Force named parameters for struct constructors (#1840)
⚠️ Breaking Changes for external bindings authors ⚠️
- The callback interface code was reworked to use vtables rather than a single callback method. See https://github.com/mozilla/uniffi-rs/pull/1818 for details and how the other bindings were updated.
- Added the
FfiType::Handlevariant. This is a general-purpose opaque handle type used for passing objects cross the FFI. This type is always 64 bits and replaces the various older handle types including:- Rust futures (replacing
FfiType::RustFutureHandlewhich was removed) - Rust future continuation data (Replacing
FfiType::RustFutureContinuationDatawhich was moved).
- Rust futures (replacing
RustBuffer.lenandRustBuffer.capacityare nowu64rather thani32.
-
-
0.26.124 Jan 2024Release notes
Open source →What's fixed?
- The weedle2 version is now
5.0.0rather than4.0.1.4.0.1was yanked because it contained a breaking change. - Fixed a memory leak in callback interface handling.
- The weedle2 version is now
-
0.26.023 Jan 2024 withdrawnRelease notes
Open source →What's changed?
- The
rust_future_continuation_callback_setFFI function was removed.rust_future_pollnow inputs the callback pointer. External bindings authors will need to update their code.
What's new?
- Rust traits
Display,HashandEqexposed to Kotlin and Swift #1817 - Foreign types can now implement trait interfaces #1791 and
the documentation
- UDL: use the
[WithForeign]attribute - proc-macros: use the
#[uniffi::export(with_foreign)]attribute
- UDL: use the
- Generated Python code is able to specify a package name for the module #1784
- UDL can describe async function #1834
- UDL files can reference types defined in procmacros in this crate - see the external types docs and also external trait interfaces #1831
- Add support for docstrings via procmacros #1862 and in UDL
- Objects can now be returned from functions/constructors/methods without wrapping them in an
Arc<>.
- The
-
0.25.307 Dec 2023Release notes
Open source →- Switched to a patched version of
oneshotso that consumers who usecargo vendordon't vendorloomand it's sub-dependencies likewindows
- Switched to a patched version of
-
0.25.220 Nov 2023Release notes
Open source →What's fixed?
-
0.25.109 Nov 2023Release notes
Open source →What's fixed?
- Fixed several bugs with async functions were defined in multiple crates that get built together.
-
0.25.018 Oct 2023Release notes
Open source →What's new
-
Proc-macros can now expose standard Rust traits (eg,
Display,Eq, etc) -
Fixed issues when trying to combine UDL and procmacros in the same crate when the "namespace" is different from the crate name. This meant that the "ffi namespace" has changed to consistently be the crate name, rather than either the crate name or the namespace name depending on whether the item was declared via a procmacro or UDL. This should be invisible in most cases, but custom build environments might require some changes. Specifically:
uniffi::generate_scaffolding(udl_path)now uses the udl_path to locate the correspondingCargo.toml, which is parsed to determine the crate name (ie, the name under the[lib]entry). If your environment is such that Cargo.toml can't be located or parsed, you should instead useuniffi::generate_scaffolding_for_crate(udl_path, crate_name).- Similarly, when executing
uniffi_bindgenfrom the command-line to generate bindings and when not using "library mode",Cargo.tomlwill be located and parsed to determine the crate name. Specifying--crate-nameon the command-line can be used to avoid this and use the specified value.
-
Crates can now use proc-macros without UDL files to export their interface. See the "Procedural Macros: Attributes and Derives" manual section for details.
-
Custom Types are now supported for proc-macros, including a very low-friction way of exposing types implementing the new-type idiom.
-
Proc-macros: Added support for ByRef arguments
-
Proc-macros: Implemented custom type conversion error handling (https://mozilla.github.io/uniffi-rs/udl/custom_types.html#error-handling-during-conversion)
-
Error types must now implement
Error + Send + Sync + 'static. -
Proc-macros: The
handle_unknown_callback_errorattribute is no longer needed for callback interface errors
What's Fixed
- Updated the async functionality to correctly handle cancellation (#1669)
- Kotlin: Fixed low-level issue with exported async APIs
- Kotlin: Fixed empty records being exported as empty data classes in Kotlin. A class with a proper
equalsfunction should be used instead.
What's changed?
- Implementing
From<uniffi::UnexpectedUniFFICallbackErroris now optional for callback interface error types. If the error type implements that, things will continue to work as before. If not, then any unexpected callback error will result in a Rust panic.
-
-
0.24.301 Aug 2023Release notes
Open source → -
0.24.225 Jul 2023Release notes
Open source →What's changed?
- Inline the metadata module in
uniffi_metato avoid a dependency ofuniffi_coreto avoid hitting an upstream bug during link time (#1666)
- Inline the metadata module in
-
0.24.123 Jun 2023 -
0.24.021 Jun 2023Release notes
Open source →⚠️ Breaking Changes ⚠️
- ABI: Implemented a new callback-interface ABI that significantly improves performance on Python and Kotlin.
- UniFFI users will automatically get the benefits of this without any code changes.
- External bindings authors will need to update their bindings code. Please see Guidance for external bindings below for details.
- ABI: Changed API checksum handling. This affects external bindings authors who will need to update their code to work with the new system. See PR #1469 for details.
- Removed the long deprecated
ThreadSafeattribute. Externaltypes now require a valid crate name. Before the docs said it must be a crate name, but any string could be used as long as it was consistent with the external type map inuniffi.toml.Externaltypes must be available in the Rust crate root.- External bindings: The
ExternalBindingsConfigtrait was replaced withBindingsConfig. External bindings implementations will need to make minor changes to implement the new trait instead. - Removed support for the
--configflag when running thescaffoldingcommand. This flag has never an effect, because there was no scaffolding configuration options. - Python bindings are now more strict with their types. You can no longer pass strings to methods taking integers or floats, or floats to methods taking integers.
What's changed
- Added "library mode" bindings generation using
generate --library [path-to-cdylib]. This mode simplifies bindings generation, especially when you have dependencies between multiple UniFFIed crates. See the tutorial for a description. - The
include_scaffolding!()macro must now either be called from your crate root or you must haveuse the_mod_that_calls_include_scaffolding::*in your crate root. This was always the expectation, but wasn't required before. This will now start failing with errors that saycrate::UniFfiTagdoes not exist. - proc-macros now work with many more types including type aliases, type paths, etc.
- The
uniffi_typesmodule is no longer needed when using proc-macros. - Traits can be exposed as a UniFFI
interfaceby using a[Trait]attribute in the UDL. See the documentation. - The
bytesprimitive type was added, it represents an array of bytes. It maps toByteArrayin Kotlin,bytesin Python,StringwithEncoding::BINARYin Ruby andDatain Swift. (#1543) - Shortened
str()representations of errors in Python to align with other exceptions in Python. Userepr()or the{!r}format to get the old representation back (#1556) - Methods implemented by standard Rust traits, such as
Debug,Display,EqandHashcan now be exposed over the FFI and bindings may implement special methods for them. See the documentation. - Added support for async/futures (#1409, #1515)
- Added constructor support to proc-macro frontend (#1518)
- Added support for field defaults to proc-macro frontend (#1560)
- Implemented proc-macro callback interface support (#1573)
- Python bindings now generate type stubs for all functions and types (#1506)
- Enforced checks for integer overflows in Python bindings (#1546)
- No more implicit conversion to integers/floats in Python (#1554)
- Enforced checks for integer overflows in Ruby bindings (#1572)
- Only UTF-8 valid strings are passed from Ruby to Rust (#1595)
- No more implicit conversion to integers/floats in Ruby (#1596)
- Updated Rust dependencies (#1495, #1583, #1569)
- Added type checking to strings/bytes for Python/Ruby (#1597)
- Implemented proc-macro external type support. This allows proc-macros to use types defined in UDL files from other crates, #1600
Guidance for external bindings
There are many breaking changes for external bindings - we hope there will be fewer in later releases, but we are laying the groundwork for some nice improvements. Significant patches to UniFFI's builtin bindings which you will need to port include:
- https://github.com/mozilla/uniffi-rs/commit/b9821439876c4fda05910313dec20906563b9909
- https://github.com/mozilla/uniffi-rs/commit/748f671bb1e88267522119ef6b9d98a8bcca1cc0
- https://github.com/mozilla/uniffi-rs/commit/07dcf3fe218d61e72073da72ba60ccbcd990bfb8
- https://github.com/mozilla/uniffi-rs/commit/45d572def4fd84120e9a8cdfcc75ff1eead00e81
- https://github.com/mozilla/uniffi-rs/commit/5e3dea51f17ae59a695a40e23479d57262968bb6
- https://github.com/mozilla/uniffi-rs/commit/2eb39753e060a28ee43eae90b996ff55f9b5e0bd
- https://github.com/mozilla/uniffi-rs/commit/323a4976992aff207db7946fc1f1cea614838f46
- https://github.com/mozilla/uniffi-rs/pull/1497
- ABI: Implemented a new callback-interface ABI that significantly improves performance on Python and Kotlin.
-
0.23.027 Jan 2023Release notes
Open source →Migrating to UniFFI 0.23+
- Update your
Cargo.tomlfile to only depend on theunifficrate. Follow the directions from the Prerequisites section of the manual - Create a
uniffi-bindgenbinary for your project. Follow the directions from the Foreign language bindings section of the manual. - Uninstall the system-wide
uniffi_bindgen:cargo uninstall uniffi_bindgen. (Not strictly necessary, but you won't be using it anymore).
⚠️ Breaking Changes ⚠️
uniffi_bindgenno longer provides a standalone binary. Having a standalone binary resulted in version mismatches when theuniffiversion specified inCargo.tomldidn't match theuniffi_bindgenversion installed on the system. Read The foreign language bindings section of the manual for how to set up auniffi-bindgenbinary that's local to your workspace.uniffi_bindgen: Removed therun_mainfunction. It's moved touniffi::uniffi_bindgen_mainand now unconditionally succeeds rather than return aResult<()>.
What's changed
- The UniFFI crate organization has been significantly reworked:
- Projects that use UniFFI for binding/scaffolding generation now only need to depend on the
unifficrate and no longer need to depend onuniffi_bindgen,uniffi_build, etc. - The version numbers for each crate will no longer by kept in sync after this release. In particular
uniffiwill have breaking changes less often thanuniffi_bindgenand other crates. This means that UniFFI consumers that specify their versions likeuniffi = "0.23"will not need to bump theiruniffiversion as often as before.
- Projects that use UniFFI for binding/scaffolding generation now only need to depend on the
- Callback interface method calls are no longer logged (#1439)
- Update your
-
0.22.016 Dec 2022Release notes
Open source →⚠️ Breaking Changes ⚠️
uniffi_bindgen: RenamedFFIArgument,FFIFunctionandFFITypetoFfiArgument,FfiFunctionandFfiType
What's changed
- Added support for Swift external types
- Fix whitespace issues in scaffolding code breaking some versions of
rustfmt - Fix ruby time support
- proc-macro
- Document (experimental) proc-macro support
- Support fallible functions
- Add Enum derive macro
- Add Error derive macro
-
0.21.116 Dec 2022Release notes
Open source →What's changed
- Replace checksum mechanism for function naming to give consistent results, independent of the target's endianness and bit width. This should have no visible effect on the outside.
-
0.21.014 Oct 2022Release notes
Open source →⚠️ Breaking Changes ⚠️
uniffi_bindgen: Renamed thethrows()method ofFunction,Method, andConstructortothrows_str(). Added a newthrows()method that returns a boolean.
What's changed
- Added support for exceptions in callback interface methods.
- Improved error stringifying on Kotlin and Ruby (the
messageandto_smethods respectively).
-
0.20.013 Sep 2022Release notes
Open source →⚠️ Breaking Changes ⚠️
- Renamed the
uniffi_bindgencydlibargument tolib_file, since it can also accept static libraries
What's changed
- The
guess_crate_rootfunction is now public
What's changed
- The UDL can contain identifiers which are also keywords in Swift, except in namespace functions.
- Renamed the
-
0.19.631 Aug 2022Release notes
Open source →- Fix callback interface init signature in Rust scaffolding
- Drop unused dependencies
- Update to MSRV 1.61.0
-
0.19.529 Aug 2022Release notes
Open source →- Fixed a small bug in the 0.19.4 release, where the extraneous
r#was present in the HashMap generated scaffolding.
- Fixed a small bug in the 0.19.4 release, where the extraneous
-
0.19.429 Aug 2022Release notes
Open source →- Implement Timestamp and Duration types in Ruby backend.
- Fixed in a bug where callback interfaces with arguments that include underscores do not get converted to camelCase on Swift.
-
0.19.308 Jul 2022 -
0.19.228 Jun 2022 -
0.19.116 Jun 2022Release notes
Open source → -
0.19.016 Jun 2022Release notes
Open source →⚠️ Breaking Changes ⚠️
- breaking for external binding generators, the
FFIType::RustArcPtrnow includes an innerString. The string represents the name of the object theRustArcPtrwas derived from. - Kotlin exception names are now formatted as strict UpperCamelCase. Most names shouldn't change, but names that use one word with all caps will be affected (for example
URL->Url,JSONException->JsonException)
What's changed
- The UDL can contain identifiers which are also keywords in Rust, Python or Kotlin.
- breaking for external binding generators, the
-
0.18.005 May 2022Release notes
Open source →⚠️ Breaking Changes ⚠️
- When custom types are used in function/method signatures UniFFI will now use
the UDL name for that type and create a typealias to the concrete type. In the
URL example,
this means the type will be now appear on Kotlin as
Urlrather thanURL. Any existing code should continue to work because of the typealias, but this might affect your generated documentation and/or code completion. - For Python libraries the native library is now loaded from an absolute path. The shared library (
*.dllon Windows,*.dylibon macOS and.soon other platforms) must be placed next to the Python wrapper code.
What's changed
- Allow record types with arbitrary key types
- Record types can now contain any hashable type as its key. This is implemented for Kotlin, Python and Swift
- Python
- Added support for default values in dictionaries
- Generated Python code is now annotated to avoid mypy type checking
- Kotlin
- Added external type support
- Swift
- Fix test helper code to work with Swift 5.6
- When custom types are used in function/method signatures UniFFI will now use
the UDL name for that type and create a typealias to the concrete type. In the
URL example,
this means the type will be now appear on Kotlin as
-
0.17.003 Feb 2022Release notes
Open source →⚠️ Breaking Changes ⚠️
- Wrapped types have been renamed custom types.
- The UDL attribute is now
[Custom]instead of[Wrapped] - The trait name has been renamed to
UniffiCustomTypeConverterfromUniffiCustomTypeWrapper - The method names of that trait have been renamed to
into_custom()/from_custom()instead ofwrap()andunwrap() - The associated type has been renamed to
Builtininstead ofWrapped
- The UDL attribute is now
What's Changed
- Custom types (formerly wrapped) now can be configured on the bindings side as well as the scaffolding side. See the "Custom Types" section of the manual for details.
- Kotlin now prefixes more local UniFFI variables with the
_char to avoid conflicts with user-defined names. - Updated Kotlin to use the
FfiConverterpattern (#1144) - Documentation updates: Added a doc comparing UniFFI to Diplomat. Added a README note describing the foreign languages we currently support.
- Fixed
RustCallStatus.__str__implementation on Python - Fixed the version numbers in the CHANGELOG compare links.
- Wrapped types have been renamed custom types.
-
0.16.015 Dec 2021Release notes
Open source →⚠️ Breaking Changes ⚠️
- Error handling when converting custom types has been updated. If your
wrap()function returns anErr, in some cases it now may not panic but instead return the error declared by the function.
What's Changed
- Python: Added Callback Interface support
- Swift bindings can now omit argument labels in generated functions using
omit_argument_labels = truein the configuration.
- Error handling when converting custom types has been updated. If your
-
0.15.224 Nov 2021Release notes
Open source →What's Changed
- Kotlin now generates valid code for optional timestamps/durations.
-
0.15.123 Nov 2021Release notes
Open source →(Note that v0.15.0 was accidentally published, then yanked. v0.15.1 should be used instead)
⚠️ Breaking Changes ⚠️
- Previously, an interface which didn't declare a constructor got a default one anyway, making it impossible to decline to provide one. This is no longer true, so if your interface wants a constructor, you must add one explicitly.
What's Changed
-
Kotlin and Swift, like Python, now support simple "wrapped" types.
-
The Python backend has been refactored to more closely match the other backends, but this should be invisible to consumers.
-
The Swift and Kotlin backends have had minor tweaks.
-
The kotlin backend now explicitly checks for a null pointer in cases where it should be impossible to help us diagnose issues seen in the wild. See #1108.
-
0.15.022 Nov 2021 withdrawnNothing published for this version
-
0.14.127 Oct 2021Release notes
Open source →⚠️ Breaking Changes ⚠️
- The
build_foreign_language_testcases!macro now takes an array of UDL files as the first argument.
What's Changed
- Swift: Added Callback Interface support
- Swift: Refactored codegen to better match Kotlin / Unit of Code
- Kotlin: Added some defensive programming around
RustBufferBuilder.discard()
- The
-
0.14.018 Aug 2021Release notes
Open source →⚠️ Breaking Changes ⚠️
-
The Rust implementations of all
dictionary,enumorerrortypes defined in UDL must be public. If you see errors like:private type <type-name> in public interfaceor similar, please declare the types aspubin your Rust code. -
Errors declared using the
[Error] enumsyntax will now expose the error string from Rust to the foreign language bindings. This reverts an unintended change in behaviour from the v0.13 release which made the error message inaccessible.
What's Changed
-
You can now use external types of various flavours - see the fine manual
-
An environment variable
UNIFFI_TESTS_DISABLE_EXTENSIONScan disable foreign language bindings when running tests. See the contributing guide for more.
-
-
0.13.110 Aug 2021Release notes
Open source →What's Changed
- Fixed an accidental regression in v0.13.0 where errors were no longer being coerced
to the correct type via
Into. If the UDL declares a[Throws=ExampleError]function or method, the underlying implementation can now return anything that isInto<ExampleError>, matching the implicitIntobehavior of Rust's?operator. - Fixed an accidental regression in v0.13.0 where the generated Rust scaffolding assumed
that the
HashMaptype would be in scope. It now uses fully-qualified type names in order to be more robust.
- Fixed an accidental regression in v0.13.0 where errors were no longer being coerced
to the correct type via
-
0.13.009 Aug 2021Release notes
Open source →⚠️ Breaking Changes ⚠️
- UniFFI no longer has ffi-support as a dependency. This means it handles
panic logging on its own. If you previously enabled the
log_panicsfeature forffi-support, now you should enable it foruniffi. - The Swift bindings now explicitly generate two separate Swift modules, one for
the high-level Swift code and one for the low-level C FFI. This change is intended
to simplify distribution of the bindings via Swift packages, but brings with it
some changes to the generated file layout.
- For an interface namespace "example", we now generate:
- A bridged C module named "exampleFFI" containing the low-level C FFI,
consisting of an
exampleFFI.hfile and matchingexampleFFI.modulemapfile. The name can be customized using theffi_module_nameconfig option. - A Swift module named "example" containing the high-level Swift bindings,
which imports and uses the low-level C FFI. The name can be customized using
the
module_nameconfig option.
- A bridged C module named "exampleFFI" containing the low-level C FFI,
consisting of an
- For an interface namespace "example", we now generate:
- Python timestamps will now be in UTC and timezone-aware rather than naive.
- Kotlin exceptions names will now replace a trailing "Error" with "Exception" rather than appending the string (FooException instead of FooErrorException)
- JNA 5.7 or greater is required for Kotlin consumers
What's Changed
- Both python and ruby backends now handle U16 correctly.
- Error variants can now contain named fields, similar to Enum variants
- Replaced the
ViaFfitrait with theFfiConvertertrait.FfiConverteris a more flexible version ofViaFfibecause it can convert any Rust type to/from an Ffi type, rather than only Self. This allows for using UniFFI with a type defined in an external crate.
- UniFFI no longer has ffi-support as a dependency. This means it handles
panic logging on its own. If you previously enabled the
-
0.12.014 Jun 2021Release notes
Open source →What's New
- It is now possible to use Object instances as fields in Records or Enums, to pass them as arguments,
and to return them from function and method calls. They should for the most part behave just like
a host language object, and their lifecycle is managed transparently using Rust's
Arc<T>type.- Reference cycles that include Rust objects will not be garbage collected; if you cannot avoid
creating reference cycles you may need to use Rust's
Weak<T>type to help break them. - In the Kotlin bindings, Object instances must be manually freed by calling their
destroy()method or by using their.useblock helper method. Records or Enums that contain an Object instance now also have adestroy()method and must be similarly disposed of after use.
- Reference cycles that include Rust objects will not be garbage collected; if you cannot avoid
creating reference cycles you may need to use Rust's
What's Changed
- Kotlin objects now implement
AutoCloseableby default; closing an object instance is equivalent to calling itsdestroy()method.
- It is now possible to use Object instances as fields in Records or Enums, to pass them as arguments,
and to return them from function and method calls. They should for the most part behave just like
a host language object, and their lifecycle is managed transparently using Rust's
-
0.11.004 Jun 2021Release notes
Open source →⚠️ Breaking Changes ⚠️
- All interface implementations must now be
Sync + Send, and Rust will give a compile-time error if they are not. This makes the[Threadsafe]annotation redundant, so it is now deprecated and will be removed in a future release. More details on the motivation for this change can be found in ADR-0004.
What's Changed
- Swift structs and Kotlin data classes generated from
dictionaryare now mutable by default:- Swift now uses
varinstead oflet - Kotlin now uses
varinstead ofval
- Swift now uses
- Kotlin objects can now safely have their
destroy()method or.useblock execute concurrently with other method calls. It's recommended that you not do this, but if you accidentally do so, it will now work correctly rather than triggering a panic in the underlying Rust code.
- All interface implementations must now be
-
0.10.026 May 2021Release notes
Open source →⚠️ Breaking Changes ⚠️
- Two new built-in datatypes have been added: the
timestamptype for representing moments in time, and thedurationtype for representing a difference between two timestamps. These mirror thestd::time::{SystemTime, Duration}types from Rust. Thanks to @npars for contributing this feature!- This is a breaking change as it may conflict with user-declared
timestampordurationtypes in existing.udlfiles.
- This is a breaking change as it may conflict with user-declared
What's New
- A new Ruby codegen backend has been added. You can now call
uniffi-bindgen -l rubyto generate a Ruby module that wraps a UniFFI Rust component. Thanks to @saks for contributing this backend!- When running
cargo testlocally, you will need a recent version of Ruby and theffigem in order to successfully execute the Ruby backend tests.
- When running
- Threadsafe Object methods can now use
self: Arc<Self>as the method receiver in the underlying Rust code, in addition to the defaultself: &Self. To do so, annotate the method with[Self=ByArc]in the.udlfile and update the corresponding Rust method signature to match. This will not change the generated foreign-language bindings in any way but may be useful for more explicit management of Object references in the Rust code.
What's Changed
- Kotlin: Fixed buggy codegen for optional primitive types like
i32?; on earlier versions this would generate invalid Kotlin code which would fail to compile.
- Two new built-in datatypes have been added: the
-
0.9.021 May 2021Release notes
Open source →⚠️ Breaking Changes ⚠️
- Support for non-
[Threadsafe]interfaces has been deprecated. A future release will require that all interface implementations beSync + Send, making the[Threadsafe]annotation redundant.
What's Changed
- Errors when parsing a
.udlfile are now marginally more useful (they're still not great, but they're better). - Generated code should now be deterministic between runs with the same input file and version of UniFFI. Previously, the generated code could depend on the iteration order of an internal hash table.
- Swift: Generated Swift Enums now conform to
Hashableby default. - Swift: There are now additional docs on how to consume the generated Swift bindings via XCode.
- Support for non-
-
0.8.005 Mar 2021Nothing published for this version
-
0.7.225 Feb 2021Nothing published for this version
-
0.7.119 Feb 2021Nothing published for this version
-
0.7.025 Jan 2021Nothing published for this version
-
0.6.109 Dec 2020Nothing published for this version