macroconf/README.md

46 lines
745 B
Markdown
Raw Permalink Normal View History

2024-04-15 21:05:19 +02:00
# macroconf
2024-04-15 20:21:09 +02:00
2024-04-15 21:05:19 +02:00
This library provides a macro to create configs with metadata attached to the values.
The [miniconf](https://github.com/quartiq/miniconf) library is used to make the metadata and the values accessible.
## Example
```rust
use miniconf::Tree;
use macroconf::config;
#[config]
#[derive(Tree)]
struct Config {
ordinary: i32,
#[min = 10]
#[max = 20]
clamped: u8
#[default = 42]
has_default: i32;
/// Doc comments are used as description
with_description: i32
}
/* The resulting miniconf tree looks like this:
* /
* |-ordinary
* |
* |-clamped
* | |-value
* | |-min
* | |-max
* |
* |-has_default
* | |-value
* | |-default
* |
* |-with_description
* |-value
* |-description
*/
```