Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Cross-Language Bindings

MoFA provides bindings for multiple programming languages through UniFFI and PyO3.

Supported Languages

LanguageMethodStatus
PythonUniFFI / PyO3Stable
JavaUniFFIBeta
GoUniFFIBeta
SwiftUniFFIBeta
KotlinUniFFIBeta

Architecture

graph TB
    A[MoFA Rust Core] --> B[UniFFI]
    A --> C[PyO3]
    B --> D[Python]
    B --> E[Java]
    B --> F[Go]
    B --> G[Swift]
    B --> H[Kotlin]
    C --> I[Native Python]

Choosing a Binding

UniFFI (Python, Java, Go, Swift, Kotlin)

Pros:

  • Consistent API across languages
  • Generated from Rust definitions
  • Type-safe

Cons:

  • Some Rust patterns don’t translate well
  • Additional binary required

PyO3 (Python Native)

Pros:

  • Native Python feel
  • Better integration with Python ecosystem
  • Async support

Cons:

  • Python-specific
  • Requires Python development headers

Installation

Python (UniFFI)

pip install mofa

Python (PyO3)

pip install mofa-native

Java (Maven)

<dependency>
    <groupId>org.mofa</groupId>
    <artifactId>mofa-java</artifactId>
    <version>0.1.0</version>
</dependency>

Go

go get github.com/mofa-org/mofa-go

Feature Flags

Enable the uniffi or python feature when building:

[dependencies]
mofa-ffi = { version = "0.1", features = ["uniffi"] }

See Also

  • Python — Python bindings
  • Java — Java bindings
  • Go — Go bindings