All top-level functions get exposed through the UDL's namespace block. For example, if the crate's file contains:

fn hello_world() -> String {
    "Hello World!".to_owned()

The UDL file will look like:

namespace Example {
    string hello_world();

Optional arguments & default values

Function arguments can be marked optional with a default value specified.

In the UDL file:

namespace Example {
    string hello_name(optional string name = "world");

The Rust code will take a required argument:

fn hello_name(name: String) -> String {
    format!("Hello {}", name)

The generated foreign-language bindings will use function parameters with default values. This works for the Kotlin, Swift and Python targets.

For example the generated Kotlin code will be equivalent to:

fun helloName(name: String = "world" ): String {
    // ...


Async functions can be exposed using the [Async] attribute:

namespace Example {
    string async_hello();

See the Async/Future support section for details.