| Crates.io | toml-configurator |
| lib.rs | toml-configurator |
| version | 0.2.8 |
| created_at | 2025-07-31 18:52:04.428167+00 |
| updated_at | 2025-12-16 22:45:41.073911+00 |
| description | Creates and manages a config.toml based on a provided configuration struct. |
| homepage | |
| repository | https://github.com/jackhamilton/configurator-rs |
| max_upload_size | |
| id | 1775504 |
| size | 19,007 |
Makes adding a configuration file to a rust program trivial.
Available via cargo:
cargo add toml-configurator
If such a file doesn't exist, one will be created with the fields initialized to their default values. If the file exists, but some fields are not there, it won't be touched but missing fields will be read as their default values.
Configuration properties can be accessed via CONFIG.[field], for example CONFIG.example_field in the below snippet.
This is another project of mine, all this means is that the given struct can be easily serialized and deserialized without messing with serde. Trait provides write_to_file() and from_file() methods, alongside to and from string methods. [https://github.com/jackhamilton/freezable] for more information.
// This macro will create a file, ~/.config/program_name/config.toml with these properties set to their defaults.
// Changes to this file will be reflected in the value of the macro-created CONFIG static.
config_builder! {
example_field: i32 = 67,
another_field: String = "test".to_string()
}
fn main() {
println!("{}" CONFIG.example_field); // Prints '67' if you haven't changed the file, or whatever int you have in there if you have.
}
~/.config/program_name/config.toml:
example_field = 67
another_field = "test"