yacm_derive 0.1.1

Macros implementation of #[derive(Yacm)]
Documentation

yacm

Yacm is yet another config macro.

Why?

Given the Long history of Yet Another projects, not even it's name is original. However, I was not finding what I wanted in a config macro and was tired of rewriting the same dull code to load structures that I subsequently passed into things that need configured.

Project Goals

  1. Dry config code
  2. Able to load config from async sources (e.g. AWS SSM Parameters)
  3. Fail fast when config is bad
  4. Make how config is loaded highly configurable

The general idea

#[derive(ConfigLoader)]
#[config_loader(prefix = "derived", name_provider = config_loader::screaming_snake_case, default_loader = config_loader::read_env)]
struct Test {
    #[config_loader(
        name = "TEST_TEST_ONE",
        default = 142u32,
        validator = less_than_100
    )]
    pub test_1: u32,
    #[config_loader(
        name = Test::load_test_1().await?,
        loader = config_loader::read_env,
    )]
    pub test_2: Option<String>,
    pub test_3: Option<String>,
}


fn less_than_100(value: u32) -> Result<u32, Box<dyn std::error::Error + Sync + Send>> {
    if value < 100 {
        Ok(value)
    } else {
        Err("should be less than 100".into())
    }
}

Road Map

  1. Use it in a few of my own projects until I have some confidence in the interface
  2. Add Testing
  3. Document

Why you shouldn't use it yet

It is brand spanking new and I have not even used it all the places I intend to yet. i.e. interface is expected to be highly volitional.

Feed back is welcome (yes, even at this early stage)

While I've been coding for 50 years, I'm new to Rust, and I'm especially new to Meta Programming in Rust. Anything from suggestions for incremental improvement, to links to crates I should be using instead of wasting my time on yet another config macro are welcome.