| Crates.io | fondant |
| lib.rs | fondant |
| version | 0.1.2 |
| created_at | 2020-03-26 07:46:49.37698+00 |
| updated_at | 2020-05-02 13:52:48.022663+00 |
| description | Macro based library to take the boilerplate out of configuration handling |
| homepage | |
| repository | https://github.com/nerdypepper/fondant |
| max_upload_size | |
| id | 223040 |
| size | 8,591 |
Documentation · Architecture · Usage · Customization · Todo
fondant is a macro based library to take the boilerplate out of
configuration handling. All you need to do is derive the
Configure trait on your struct, and fondant will decide
where to store it and and how to do so safely.
Most of fondant is based off the confy crate,
with a couple of extra features:
Drop this in your Cargo.toml to get started:
[dependencies]
fondant = "0.1.0"
Derive the macro:
// the struct has to derive Serialize, Deserialize and Default
use fondant::Configure;
use serde::{Serialize, Deserialize};
#[derive(Configure, Serialize, Deserialize, Default)]
#[config_file = "config.toml"]
struct AppConfig {
port: u32,
username: String,
}
fn main() {
// use `load` to load the config file
// loads in Default::default if it can't find one
let mut conf = AppConfig::load().unwrap();
// do stuff with conf
conf.port = 7878;
// call `store` to save changes
conf.store().unwrap();
}
Find more examples and options at docs.rs.
fondant is split into 3 separate crates:
fondant_deps: external crates and utils that fondant requiresfondant_derive: core macro definitionsfondant: the user facing library that brings it all togetherThis slightly strange architecture arose because of some
limitations with proc-macro crates and strict cyclic
dependencies in cargo. All you need is the fondant crate.
syn::Error and syn::Result to report macro errors