Crates.io | ronfig |
lib.rs | ronfig |
version | 0.1.1 |
source | src |
created_at | 2021-02-03 19:59:40.895333 |
updated_at | 2021-04-09 19:25:10.248834 |
description | Config rust with RON, Easily! |
homepage | |
repository | https://github.com/mojtab23/ronfig |
max_upload_size | |
id | 350205 |
size | 15,795 |
Config rust with RON, Easily!
For now, it's just a copy of amethyst_config.
Add this to Cargo.toml
[dependencies]
ronfig = "0.1"
Example RON file
(
app_name:"simple app",
workers: 4,
debug: Some(true),
)
use std::path::Path;
use serde::{Deserialize, Serialize};
use ronfig::Config;
/// Your struct should at least derive `serde`'s `Serialize` and `Deserialize` to
/// be able to read and write the ron file.
#[derive(Debug, Deserialize, Serialize)]
struct SimpleConfig {
app_name: String,
workers: usize,
debug: Option<bool>,
}
fn main() {
let path = Path::new("./resources/examples/simple-config.ron");
let result = SimpleConfig::load(path);
match result {
Ok(simple_config) => {
println!("Config loaded from file:\n\t {:?}", &path);
println!("{:?}", &simple_config);
}
Err(config_error) => {
println!("Error loading the config:\n\t{:?}", &config_error);
}
};
}