tuffite0.1
A FOUNDATION FOR YOUR NEXT APP

Create a Rust application

From an empty folder to a typed desktop application.

Experimental source release. Production hardening and published SDK packages are still in progress.

Scaffold the project#

Install the CLI as described in Quick start. tuff init creates Cargo.toml, build.rs, src/lib.rs, shell_api.d.ts, tuffite.json, a small HTML frontend, and generated bindings. The directory must be empty. The generated project depends on the matching published tuffite SDK.

shell
tuff init my-app
cd my-app
tuff check
tuff build --release

Use the published SDK#

The application uses the Rust library; build.rs enables the build helpers for runtime resolution and binding generation. Keep the SDK version aligned with the CLI that created the project. A compatible Framework Distribution is resolved automatically during native builds.

toml
[dependencies]
tuffite = { version = "0.1.0", default-features = false }

[build-dependencies]
tuffite = { version = "0.1.0", default-features = false, features = ["build"] }

Implement the application lifecycle#

Browser::new receives BrowserContext only in the browser process. #[tuffite::browser] marks the implementation; #[tuffite::main] exports the ABI entry table and app::Builder registers commands explicitly. Handler types are checked against the generated endpoint declarations at compile time.

rust
use tuffite::{BrowserContext, Browser, ApplicationResult, CommandError};

mod shell_api {
    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}

struct App;
#[tuffite::browser]
impl Browser for App {
    fn new(_context: BrowserContext) -> ApplicationResult<Self> { Ok(Self) }
}

#[tuffite::main(browser = App)]
fn main() -> tuffite::app::Builder<App> {
    tuffite::app::Builder::new().commands(tuffite::generate_handler![ping])
}

#[tuffite::command(shell_api::commands::Ping)]
fn ping(_app: &mut App, message: String) -> Result<String, CommandError> {
    Ok(message)
}