Skip to main content

cratefield_runtime_native/
config.rs

1//! `Config` over the process environment (`std::env`), the native
2//! counterpart of the Workers `Env` adapter in
3//! `cratefield-runtime-cloudflare`. Modules still never touch `std::env`:
4//! they receive the same [`Config`] trait object, filled here.
5
6use cratefield_core::Config;
7
8/// Reads `SCREAMING_SNAKE` keys from the process environment. Secrets and
9/// plain variables are the same thing natively — there is no separate
10/// secret store, so the deployment (Docker, systemd) owns secret
11/// injection (see the crate README's compose example).
12#[derive(Debug, Clone, Copy, Default)]
13pub struct EnvConfig;
14
15impl Config for EnvConfig {
16    fn get(&self, key: &str) -> Option<String> {
17        std::env::var(key).ok().filter(|value| !value.is_empty())
18    }
19}