aboutsummaryrefslogtreecommitdiff
path: root/readme.md
blob: 1e6de1ee52c4fd97dcbbd6795f27edf70fcd5e1b (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
# 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"]
```