1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use serde::de::DeserializeOwned;
use serde::Serialize;

pub trait DynConfigurationKey {
    type Value: DeserializeOwned + Serialize;

    fn path(&self) -> &'static str;
}

#[macro_export]
macro_rules! configuration_keys {
    ($($key_ident:ident($key:literal, $value:ident)),* ) => {
        $(
            pub struct $key_ident;
            impl $crate::dyn_configuration::DynConfigurationKey for $key_ident {
                type Value = $value;
                fn path(&self) -> &'static str {
                    $key
                }
            }
        )*
    };
}