twelf icon indicating copy to clipboard operation
twelf copied to clipboard

Environment names for nested structs?

Open Natureshadow opened this issue 1 year ago • 0 comments

Assuming a (simplified) structure like:

#[derive(Deserialize, Serialize])
struct NetworkConfig {
    host: String,
    port: u16,
}

#[config]
struct Config {
    network: NetworkConfig,
}

I am trying to figure out how to achieve the following environment variable names:

  • APP_NETWORK_HOST for the host field
  • APP_NETWORK_PORT for the port field

What I find in the project examples is flattening into APP_HOST and APP_PORT, which I explicitly do not want (my intention is to get my struct layers as "namespaces" in the environment variables).

Along those lines, I'd also want a TOML schema resulting out of this to be

[network]
host = "127.0.0.1"
port = 4711

Any hints are much appreciated!

Natureshadow avatar Feb 15 '24 23:02 Natureshadow