Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment names for nested structs? #39

Open
Natureshadow opened this issue Feb 15, 2024 · 0 comments
Open

Environment names for nested structs? #39

Natureshadow opened this issue Feb 15, 2024 · 0 comments

Comments

@Natureshadow
Copy link

Natureshadow commented Feb 15, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant