https://github.com/meloencoding/carpenter
Create multiple config files easily
https://github.com/meloencoding/carpenter
Last synced: 9 months ago
JSON representation
Create multiple config files easily
- Host: GitHub
- URL: https://github.com/meloencoding/carpenter
- Owner: MeloenCoding
- License: mit
- Created: 2023-11-10T11:02:23.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-11T13:42:32.000Z (over 2 years ago)
- Last Synced: 2025-02-28T07:04:17.232Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Carpenter
Create multiple config files easily.
## Support
- Support for all Sized integers
- Support for Strings
- Lightweight
- Saves as binary for small file size
## Installation/Usage
#### Installation
To use this crate you need these dependencies:
```toml
[dependencies]
bytestream = "0.4.1"
carpenter = "0.1.0"
```
#### Usage
```rust
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
);
// 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());
}
```
## Config file in a HxD
- Byte order is *Big endian*.
- **i32** = 4 bytes so 0x00-0x03 is 0x00_00_01_90 which is 400 in decimal.
- **bool** = 1 byte so 0x04-0x04 is 0x01 which is true in rust.
- **String** = is in this case 4 bytes so 0x05-0x08 is 0x48_65_79_00 which is "Hey\0". String gets null terminated.
