Crates.io | carpenter |
lib.rs | carpenter |
version | 0.1.0 |
source | src |
created_at | 2023-11-11 13:52:41.922836 |
updated_at | 2023-11-11 13:52:41.922836 |
description | Create multiple config files easily. |
homepage | https://github.com/MeloenCoding/carpenter |
repository | https://github.com/MeloenCoding/carpenter |
max_upload_size | |
id | 1032070 |
size | 3,741 |
Create multiple config files easily.
To use this crate you need these dependencies:
[dependencies]
bytestream = "0.4.1"
carpenter = "0.1.0"
use carpenter::ConfigManager;
// Create a struct and derive it with ConfigManager
#[derive(ConfigManager, PartialEq, Debug)]
struct Config {
_a: i32,
_b: bool,
_c: String,
}
fn main() {
// Create config builder
let config_factory = Config::init_config(
"meloencoding", // username
"config-rs-test", // application name
"test.bin" // config file name
);
// Lin: /home/alice/.config/{application name}/{config file name}
// Win: C:\Users\Alice\AppData\Roaming\{username}\{application name}\config/{config file name}
// Mac: /Users/Alice/Library/Application Support/com.{username}.{application name}
/{config file name}
// To save your config
let sample_config = Config {
_a: 400,
_b: true,
_c: String::from("Hey"),
};
config_factory.save(&sample_config);
// To read the saved config
assert_eq!(sample_config, config_factory.read());
}