#macro #miniconf

macro macroconf

macro for creating configurations using miniconf

1 unstable release

new 0.1.0 Apr 23, 2024

#407 in Configuration

MIT/Apache

21KB
485 lines

macroconf

This library provides a macro to create configs with metadata attached to the values. The miniconf library is used to make the metadata and the values accessible.

Example

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
 */

lib.rs:

This crate creates miniconf::Tree implementations fields in a struct. These carry some extra extra information about the field.

Dependencies

~0.9–1.4MB
~27K SLoC