foundry_config

Macro merge_impl_figment_convert

Source
macro_rules! merge_impl_figment_convert {
    ($name:ty, $start:ident $(, $more:ident)*) => { ... };
}
Expand description

Same as impl_figment_convert but also merges the type itself into the figment

ยงExample

Merge several nested Provider together with the type itself

use foundry_config::{
    figment::{value::*, *},
    impl_figment_convert, merge_impl_figment_convert, Config,
};
use std::path::PathBuf;

#[derive(Default)]
struct MyArgs {
    root: Option<PathBuf>,
}

impl Provider for MyArgs {
    fn metadata(&self) -> Metadata {
        Metadata::default()
    }

    fn data(&self) -> std::result::Result<Map<Profile, Dict>, Error> {
        todo!()
    }
}

impl_figment_convert!(MyArgs);

#[derive(Default)]
struct OuterArgs {
    value: u64,
    inner: MyArgs,
}

impl Provider for OuterArgs {
    fn metadata(&self) -> Metadata {
        Metadata::default()
    }

    fn data(&self) -> std::result::Result<Map<Profile, Dict>, Error> {
        todo!()
    }
}

merge_impl_figment_convert!(OuterArgs, inner);