A small and easy-to-use Rust crate to handle config files. Currently only supports: JSON5, TOML, and YAML. But more formats are planned to be added later.
I've accidentally stumbled across a crate with the exact same name my crate had, made by someone with way more experience than me, who's crate also does the exact same things but better.
I swear I checked Crates.io right before naming my project simple_config
Either way, this project is now called fast_config
, because it's the only name available.
Feel free to check out the other, way better simple_config
here.
(I don't have any affiliation with it, only bad luck by crates.io somehow bugging out when i chose the original name)
I will still continue work on this project, for use in my own projects, but I wouldn't recommend other people using it XD
I'm still working on this crate, and it's in somewhat-early-access. While I haven't managed to find any bugs myself, documentation might be a little weird or uncomplete at the current moment.
```rust use fast_config::Config; use serde::{Serialize, Deserialize};
// Creating a config struct to store our data
pub struct MyData { #[serde(default = "MyDataDefaults::studentdebt")] pub studentdebt: i32 }
// Storing the default values for our data pub struct MyDataDefaults; impl MyDataDefaults { pub fn student_debt() -> i32 { 20 } }
fn main() { // Initializing a logging system (needed to show errors) env_logger::init();
// Creating a new config struct with our data struct (it can also guess the file extension)
let mut config = Config::<MyData>::new("./config/myconfig");
// Read/writing to the data
println!("I am ${} in debt", config.data.student_debt);
config.data.student_debt = i32::MAX;
println!("Oh no, i am now ${} in debt!!", config.data.student_debt);
// Saving it back to the disk
config.save();
} ```
View the examples directory for more advanced examples.