A build is the start of shipping.
Package a tool with configuration, tests, and an operational contract.
01 Understand the contract
cargo build --release produces an optimized binary for a selected target. That does not make a binary portable across every operating system, architecture, or C library. A deployable service also needs configuration, health checks, graceful shutdown, logs, and an explicit persistence model. Desktop applications add platform dependencies, bundling, and signing. The cookbook includes local runnable projects and describes the next production decisions beside each one. Review dependency updates and lockfile changes as part of maintaining the application, not just launching it.
02 Make it concrete
This is a complete standard-library example. Use Rust stable with the 2024 edition. Run it locally using the Rust workbench.
use std::time::Duration;
fn main() {
let shutdown_budget = Duration::from_secs(10);
let environment = "local";
println!(
"mode={environment}, shutdown={}s",
shutdown_budget.as_secs()
);
}mode=local, shutdown=10s
- 1
A shutdown budget is an operational policy, not automatic cancellation.
- 2
Use configuration at the application boundary.
- 3
The cookbook shows ctrl_c handling and a local-only default address.
cargo run -p lesson_shipping03 Mind the boundary
04 Your next build
Define a small validated configuration type with a nonzero port.
Reveal one possible solution +
struct Config {
port: u16,
}
fn config(port: u16) -> Result<Config, &'static str> {
if port == 0 {
Err("explicit port required")
} else {
Ok(Config { port })
}
}
fn main() {
assert!(config(0).is_err());
assert_eq!(config(3000).unwrap().port, 3000);
}05 Check your reasoning
Does a successful release build establish production readiness?
Understand it.
Then make it yours.
Run the example, try your own input, and explain the boundary. Log the lesson when the idea makes sense.