The generated Kotlin modules can be configured using a uniffi.toml configuration file.

Available options

Configuration nameDefaultDescription
package_nameuniffiThe Kotlin package name - ie, the value used in the package statement at the top of generated files.
cdylib_nameuniffi_{namespace}1The name of the compiled Rust library containing the FFI implementation (not needed when using generate --library).
generate_immutable_recordsfalseWhether to generate records with immutable fields (val instead of var).
custom_typesA map which controls how custom types are exposed to Kotlin. See the custom types section of the manual
external_packagesA map of packages to be used for the specified external crates. The key is the Rust crate name, the value is the Kotlin package which will be used referring to types in that crate. See the external types section of the manual
androidfalseUsed to toggle on Android specific optimizations
android_cleanerandroidUse the android.system.SystemCleaner instead of java.lang.ref.Cleaner. Fallback in both instances is the one shipped with JNA.


Custom types

# Assuming a Custom Type named URL using a String as the builtin.
# Name of the type in the Kotlin code
type_name = "URL"
# Classes that need to be imported
imports = [ "", "" ]
# Functions to convert between strings and URLs
into_custom = "URI({}).toURL()"
from_custom = "{}.toString()"

External types

# This specifies that external types from the crate `rust-crate-name` will be referred by by the package `"`.
rust-crate-name = ""