envconfig-rs
envconfig-rs copied to clipboard
Automatically detect name for nested structs
I love this lib, simple and straight forward, thanks!
Just one thing that would be nice to have: In a case like this:
#[derive(Envconfig, Debug)]
struct ProxyAuthConfig {
enabled: bool,
headers_username: Option<String>,
headers_password: Option<String>,
}
#[derive(Envconfig, Debug)]
struct LocalAuthConfig {
enabled: bool,
}
#[derive(Envconfig, Debug)]
struct AuthConfig {
#[envconfig(nested = true)]
proxy: ProxyAuthConfig,
#[envconfig(nested = true)]
local: LocalAuthConfig,
}
#[derive(Envconfig, Debug)]
pub struct ConfigurationService {
jwt_secret: String,
#[envconfig(nested = true)]
auth: AuthConfig,
}
the auth.local.enabled would be named AUTH_LOCAL_ENABLED by default :)
As alternative it would be nice, if a prefix can manual defined at struct level or with the #[envconfig(nested = true)] attribute.