Skip to content

Cargo Integration

Krait edited this page May 28, 2026 · 1 revision

KOSL can be utilized as a cleaner alternative for configuring Rust workspace manifests. Instead of writing standard Cargo.toml, you can maintain a Cargo.kosl file and compile/transpile it automatically.

Mapping Syntax Rules

Cargo.toml Structure Cargo.kosl Syntax
Standard Section Object mapping package=(...)
Nested Objects Nested parentheses dependencies=(...)
Arrays of Tables List of objects bin=[(...), (...)]

Code Translation Example

Source: Cargo.kosl

package=(
  name=my_project,
  version=0.1.0,
  edition=2021
)

dependencies=(
  rand=0.8.5,
  serde=(
    version=1.0,
    features=[derive]
  )
)

bin=[
  (
    name=cli,
    path=src/main.rs
  )
]

Transpiled Result: Cargo.toml

[package]
name = "my_project"
version = "0.1.0"
edition = "2021"

[dependencies]
rand = "0.8.5"

[dependencies.serde]
version = "1.0"
features = ["derive"]

[[bin]]
name = "cli"
path = "src/main.rs"

Automation Hook

To keep your files updated automatically during local development builds, you can add a pre-build step to your shell alias or continuous integration script:

kosl transpile Cargo.kosl && cargo build

Clone this wiki locally