#bindgen

uniffi_bindgen

a multi-language bindings generator for rust (codegen and cli tooling)

47 releases (25 breaking)

0.26.1 Jan 24, 2024
0.25.3 Dec 7, 2023
0.25.2 Nov 20, 2023
0.24.2 Jul 25, 2023
0.5.0 Nov 9, 2020

#23 in FFI

Download history 13604/week @ 2023-11-09 11618/week @ 2023-11-16 11964/week @ 2023-11-23 14218/week @ 2023-11-30 11990/week @ 2023-12-07 13027/week @ 2023-12-14 6889/week @ 2023-12-21 7870/week @ 2023-12-28 10337/week @ 2024-01-04 12812/week @ 2024-01-11 16755/week @ 2024-01-18 16039/week @ 2024-01-25 17117/week @ 2024-02-01 17716/week @ 2024-02-08 16359/week @ 2024-02-15 14917/week @ 2024-02-22

69,261 downloads per month
Used in 22 crates (6 directly)

MPL-2.0 license

785KB
17K SLoC

Rust 11K SLoC // 0.1% comments Kotlin 1.5K SLoC // 0.2% comments Python 1.5K SLoC // 0.1% comments Swift 1.5K SLoC // 0.1% comments Ruby 1K SLoC // 0.1% comments

UniFFI - a multi-language bindings generator for Rust

UniFFI is a toolkit for building cross-platform software components in Rust.

For the impatient, see the UniFFI user guide or the UniFFI examples.

By writing your core business logic in Rust and describing its interface in an "object model", you can use UniFFI to help you:

  • Compile your Rust code into a shared library for use on different target platforms.
  • Generate bindings to load and use the library from different target languages.

You can describe your object model in an interface definition file or by using proc-macros.

UniFFI is currently extensively by Mozilla in Firefox mobile and desktop browsers; written once in Rust, auto-generated bindings allow that functionality to be called from both Kotlin (for Android apps) and Swift (for iOS apps). It also has a growing community of users shipping various cool things to many users.

UniFII comes with support for Kotlin, Swift, Python and Ruby with 3rd party bindings available for C# and Golang. Additional foreign language bindings can be developed externally and we welcome contributions to list them here. See Third-party foreign language bindings.

User Guide

You can read more about using the tool in the UniFFI user guide.

We consider it ready for production use, but UniFFI is a long way from a 1.0 release with lots of internal work still going on. We try hard to avoid breaking simple consumers, but more advanced things might break as you upgrade over time.

Etymology and Pronunciation

ˈjuːnɪfaɪ. Pronounced to rhyme with "unify".

A portmanteau word that also puns with "unify", to signify the joining of one codebase accessed from many languages.

uni - [Latin ūni-, from ūnus, one] FFI - [Abbreviation, Foreign Function Interface]

Alternative tools

Other tools we know of which try and solve a similarly shaped problem are:

(Please open a PR if you think other tools should be listed!)

Third-party foreign language bindings

External resources

There are a few third-party resources that make it easier to work with UniFFI:

(Please open a PR if you think other resources should be listed!)

Contributing

If this tool sounds interesting to you, please help us develop it! You can:

Code of Conduct

This project is governed by Mozilla's Community Participation Guidelines.

Dependencies

~5.5MB
~104K SLoC