Open plinto
Docs›Languages

Rust

Language·3 min read
In one sentence

RustBuild builds a Cargo crate with the Rust your group pins and, on Linux, links it with plinto's own C toolchain, so the machine needs no compiler and every build links the same way.

Build systemRustBuild
Start oneplinto create rust-service HelloApp (or rust-lib)
Ships asa binary in an archive, for Linux back to Debian 11

The project

src/lib.rs makes a library, and a crate that names its binary's root, main = src/main.rs, a program; a crate can be both. Integration tests are tst/<name>.rs. Crates use edition 2024.

plinto.conf
{
  name = HelloApp
  version = 1.0
  build = RustBuild
  main = src/main.rs   # a program: what `plinto run` starts

  build-dependencies: {
    RustBuild = 1.0
    Rust = 1.98
  }
  dependencies: {
    Serde: { version = 1.0.229, features = [derive] }
  }
}

main can name another file, such as src/server.rs. args = [--port, 8080] is what the program starts with, for plinto run and once packaged.

Not yet: build scripts (build.rs) don't run.

The C toolchain

On Linux, the Rust package brings Gcc and Glibc as packages, and RustBuild links with those only, never with the machine's cc. Each build says which:

using Rust 1.98.1, linking with Gcc 15.2.0, Glibc 2.31

A binary needs a Linux whose glibc is at least as new as the one it was linked with: with Glibc 2.31, Debian 11's, as groups start, it runs on Debian 11 and newer. On macOS, Rust links with the system's toolchain.

Builds and releases

plinto build and plinto run use Cargo's dev profile; a release is optimized and stripped of debug information. A program's release is HelloApp-1.0-bin-<platform>.tar.gz, built for the machine it builds on.

Crates

$ plinto import crate serde@1.0.229 --features derive

The features an import turns on decide which optional crates it brings, and a project turns on those it needs, as features = [derive] above.