std/toml parses TOML configuration strings into a flat Map with dot-notation keys. TOML is the configuration format used by nyx.toml (the package manager manifest) and by any service that keeps its settings in a .toml file.
// Parsing TOML configuration strings // Parseo de cadenas de configuración TOML import "std/toml" fn main() -> int { let config: String = "[server]\nhost = \"localhost\"\nport = 8080\ndebug = true\n\n[database]\npath = \"/var/data/app.db\"\nmax_connections = 50" let parsed: Map = toml_parse(config) // Get string values with defaults let host: String = toml_get(parsed, "server.host", "0.0.0.0") print("host: " + host) // Get integer values let port: int = toml_get_int(parsed, "server.port", 3000) print("port: " + int_to_string(port)) // Get boolean values let debug: bool = toml_get_bool(parsed, "server.debug", false) if debug { print("debug mode enabled") } // Check if a key exists if toml_has(parsed, "database.path") { let db_path: String = toml_get(parsed, "database.path", "") print("db: " + db_path) } return 0 }
host: localhost port: 8080 debug mode enabled db: /var/data/app.db
How it works
toml_parse reads a TOML string and returns a Map<String> where section keys use dot notation: [server] + host = "localhost" becomes "server.host" → "localhost". All values are stored as strings internally.
Typed accessors — toml_get (string), toml_get_int, toml_get_bool — convert from the string representation and accept a default value if the key is missing. toml_has checks whether a key exists without reading its value.
This is the same parser nyx build uses to read nyx.toml project manifests, and the one you reach for when a server has to load its routing table from a .toml file at startup.