Edit source

Rust target configuration

All fields belong under the selected target’s options object. Unknown fields are rejected.

OptionTypeDefaultContract
crateNamenonempty string matching [a-z][a-z0-9_]*tsonic_generatedGenerated Cargo package and crate name
edition2021 or 20242021Rust edition used by the generated project
foundationcore, alloc, or stdstdMaximum Rust language/runtime foundation
outputTypelib or binlibGenerated Cargo target kind
projectFilenonempty stringnoneExisting user-owned Cargo.toml

outputType: "bin" requires foundation: "std". core and alloc executables require startup, panic, allocator, linker, and platform policies that belong to a user-owned native project.

Generated and user-owned projects

OptionGenerated projectUser-owned project
crateNameCargo package/crate nameemitted Rust crate identity where applicable
editionemitted in Cargo.toml and used by generated Rustused by generated Rust; the manifest must agree
foundationselects crate root and runtime featuresselects legal source semantics; the manifest must supply matching features
outputTypecreates src/lib.rs or src/main.rscontrols emitted library/binary contract; native startup still belongs to Cargo
projectFileabsentselects the existing Cargo.toml

Rust has no free-form target properties object. Target triples, profiles, features, linkers, build scripts, workspace layout, and packaging are Cargo configuration and belong in a user-owned project.

projectFile

The resolved file must:

  • exist and be a regular file named Cargo.toml;
  • remain outside the generated Rust output root;
  • describe the direct dependencies used by @tsonic/rust/crates/* imports.

In user-owned mode Tsonic emits sources only. It never reads Cargo project settings as hidden semantic evidence and never mutates the manifest.

Direct Cargo dependency aliases are semantic input for imports such as:

import { Widget } from "@tsonic/rust/crates/widget_alias/index.js";

The configured manifest must declare widget_alias directly. Transitive dependencies and package-name guessing are not searched.

Complete generated example

{
  "id": "rust",
  "surfaces": ["js"],
  "options": {
    "crateName": "acme_tool",
    "edition": "2024",
    "foundation": "std",
    "outputType": "bin"
  }
}