iet-config-env
feature implementation official
Snapshots the process environment once; no dotenv or background reload.
CoreFeaturesIntegrationsStacksTooling
Used byno framework crate yetexamples/handbook-notesexamples/htmx-starterexamples/skills-only-app
iet-config-envimplementationEnvironment configuration sourceDepends oniet-corecontractiet-configcontract
How to use it
iet-config-env reads one immutable snapshot of process environment variables and exposes it as an iet-config source. Give it an uppercase prefix; the prefix is stripped and the rest becomes the logical key that ConfigLoader maps onto a typed configuration struct.
// examples/handbook-notes/src/main.rs (type from src/config.rs)
use ConfigLoader;
use EnvSource;
// APP_DATABASE_URL is looked up as DATABASE_URL under prefix APP.
// NOTES_HTTP_ADDRESS here maps to `http_address`.
let source = snapshot?;
let config: NotesConfig = new.load?;
- Prefixes and keys must match
[A-Z][A-Z0-9_]*(max 128 chars); unrelated or non-Unicode keys are ignored, while a malformed selected value fails startup instead of falling back. - Duplicate selected keys are an error, and
Secretvalues never appear inDebugoutput or error messages. - For deterministic tests, use
EnvSource::from_iter("NOTES", entries)instead of mutating the process environment.
How it works
EnvSource::snapshot reads the process environment once; only keys with the uppercase prefix and a valid suffix are kept, and each value is wrapped in a Secret. The resulting EnvSource implements the iet-config ConfigSource trait, and ConfigLoader::load reads the logical keys out of it, applies defaults and ranges, and builds the typed struct.
flowchart LR
A["EnvSource::snapshot"] --> B["process environment"]
B --> C["strip prefix"]
C --> D{"identifier valid"}
D -->|no| E["config.env_key error"]
D -->|yes| F["Secret value"]
F --> G["ConfigSource::get"]
G --> H["ConfigLoader::load"]
H --> I["typed configuration struct"]What it implements
- Implements
iet_config::ConfigSourcefromiet-config.
What's inside
Modules
src/lib.rs
Public API
(root)
- struct
EnvSource pub fn snapshot(prefix: &str) -> AppResult<Self>— APP_DATABASE_URL is looked up as DATABASE_URL under prefix APP.pub fn from_iter( prefix: &str, entries: impl IntoIterator<Item = (OsString, OsString)>, ) -> AppResult<Self>— Deterministic/test source without mutating global process environment.
Impl map
ConfigSource for EnvSource
Depends on
Used by
- No other framework crate depends on it directly.
In this repository
examples/handbook-notesexamples/htmx-starterexamples/skills-only-appexamples/skills-only-app-task-tracker
Source: crates/features/iet-config-env