CONNECT YOUR APP

Use the combination selected for each installation

Your application ships as one program containing every accepted implementation. Each installation receives a list telling it which implementation to use for every specified function. You do not build a separate program for every possible combination.

1. Add the current Rust runtime

Download the open-source Polyform code, place it beside your project, and add the runtime library as a local dependency:

[dependencies]
polyform-runtime = { path = "../polyform/crates/polyform-runtime" }

This is ordinary Rust dependency syntax. No separate package-registry account is needed.

2. Register this installation

use polyform_runtime::Client;

let client = Client::register(
    "https://omalled.com/polyform",
    release_id,
    Some(installation_id),
    "balanced",
)?;

Polyform returns one implementation ID for every function in the release.

3. Call the selected implementation

let selected = client.composition.implementations
    .get("decode_filename")
    .map(String::as_str)
    .unwrap_or("decode_filename.strict_utf8");

let result = match selected {
    "decode_filename.strict_utf8" => strict_utf8(bytes, flags),
    "decode_filename.table_driven" => table_driven(bytes, flags),
    other => return Err(format!("unknown implementation: {other}")),
};

The generated code adds this registration and dispatch structure. Private helpers remain part of their own implementation and are not selected separately.

4. Receive replacements

if client.refresh()? {
    // Use the new combination for later calls.
}

Call refresh between units of work—for example, when the app starts, before a new job, or every few minutes. If you quarantined an implementation, this call gives affected installations a replacement.