Expand description
§confroid
Your config on ’roids — a small, type-driven reader for environment-based configuration.
Derive Config on a struct and read it with from_env:
#[derive(confroid::Config)]
struct Config {
#[confroid(default = 8080)]
port: u16,
}
// Reads the `PORT` environment variable, falling back to 8080.
let config: Config = confroid::from_env().unwrap();Macros§
- from_
str_ scalar - Register one or more types as confroid scalars (see the
docs-disabled variant for details). With thedocsfeature this also implementsDocumented, so the type can appear in a config that generates documentation. In that case the type should also implementDisplayif it is used with adefault/example.
Structs§
- Ctx
- The naming context for the field currently being read.
- Env
- A snapshot of environment variables.
- Field
Doc - A single field in a config’s documentation tree.
Enums§
- Confroid
Error - The error type returned by
from_envand theFromEnvtrait.
Traits§
- Documented
- A type that can describe its configuration shape for documentation.
- FromEnv
- A type that can be read from the environment at a given
Ctx.
Functions§
- env_
example - Render
Tas a.env.example-style file. - from_
env - Read
Tfrom the current process environment. - from_
pairs - Read
Tfrom an explicit set of variables instead of the process environment. Useful for tests and for reading a curated variable set. - from_
snapshot - Read
Tfrom an existingEnvsnapshot. - markdown_
table - Render
Tas a Markdown table of every (leaf) variable.
Type Aliases§
- Parser
Error - A boxed parser error retained as the source of an invalid-value error.
- Result
- Convenient result alias.
Derive Macros§
- Config
- Derive
confroid::FromEnvfor a named struct. - Config
Value - Derive
confroid::FromEnvfor a scalar configuration value.