Toml-scaffold: Generate Commented TOML Config Files from Rust Structs
⚓ Rust 📅 2026-02-03 👤 surdeus 👁️ 11I'm excited to share toml-scaffold v0.1, a library that generates TOML configuration scaffold files directly from your Rust structs while preserving doc comments.
What It Does
Turn this:
#[derive(Serialize, JsonSchema, TomlScaffold)]
struct Config {
/// Server host address
host: String,
/// Server port
port: u16,
}
let config = Config {
host: "localhost".to_string(),
port: 8080,
};
Into this:
# Server host address
host = "localhost"
# Server port
port = 8080
Key Features
- Doc comments become TOML comments - Your documentation flows directly into
config files - Field order preserved - Output matches your struct definition
- Comprehensive type support - Primitives, Option, HashMap, Vec, nested
structs, and serde_json::Value
Use Cases
- Generate example configuration files for your CLI tools
- Create documented config templates for users
- Bootstrap configuration with sensible defaults
Check it out on crates.io and GitHub.
1 post - 1 participant
🏷️ Rust_feed