Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oppiliappan/fondant
macro based configuration management library
https://github.com/oppiliappan/fondant
Last synced: 2 months ago
JSON representation
macro based configuration management library
- Host: GitHub
- URL: https://github.com/oppiliappan/fondant
- Owner: oppiliappan
- License: mit
- Created: 2020-03-15T16:43:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-02T13:52:22.000Z (over 4 years ago)
- Last Synced: 2024-10-11T23:40:05.905Z (3 months ago)
- Language: Rust
- Homepage: https://crates.io/crates/fondant
- Size: 29.3 KB
- Stars: 60
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# fondant
[Documentation](https://docs.rs/fondant/) ·
[Architecture](#Architecture) · [Usage](#Usage) ·
[Customization](#Customization) · [Todo](#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:- support for json, yaml and toml
- support for custom config paths
- support for custom config file names### Usage ([Full Documentation](https://docs.rs/fondant/))
Drop this in your `Cargo.toml` to get started:
```
[dependencies]
fondant = "0.1.0"
```Derive the macro:
```rust
// 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](https://docs.rs/fondant/).
### Architecture
`fondant` is split into 3 separate crates:
- `fondant_deps`: external crates and utils that `fondant` requires
- `fondant_derive`: core macro definitions
- `fondant`: 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.### Todo
- [x] improve error types
- [ ] use `syn::Error` and `syn::Result` to report macro errors
- [x] write docs
- [ ] write test suite
- [x] bundle and publish to crates.io