aboutsummaryrefslogtreecommitdiff
path: root/readme.md
blob: 3445327519c3effae2299fd588e8e7dd4dfb4d1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# fondant

> an experimental, macro-only, boilerplate free, configuration management library

### example

```rust
// derive the `Configure` trait, and specify the
// `config_file` attribute
#[derive(Configure, Default, Serialize, Deserialize)]
#[config_file = "config.toml"]
struct AppConfig {
    -- snip --
}

// `Configure` exposes `load` and `store`
fn main() {
    let mut config = AppConfig::load().unwrap();
    config.version = 2;
    config.path = "/home/np".to_string();
    config.store();
}
```

You can specify a path to be used, unless you want to stick
with the defaults:

```rust
// load from and store in user's home directory
#[config_file = "~/config.toml"]
```

`fondant` supports `yaml`, `toml` and `json`, defaults to
`toml`:

```rust
#[config_file = "config.toml"]
#[config_file = "my_app_config.yaml"]
#[config_file = "~/.app.conf.json"]
```

### todo

 - [ ] improve error from trait impl
 - [ ] use `syn::Error` and `syn::Result` to report macro errors
 - [ ] write docs
 - [ ] bundle and publish to crates.io