Crates.io | de_env |
lib.rs | de_env |
version | 1.0.0 |
source | src |
created_at | 2022-05-01 13:16:17.666469 |
updated_at | 2022-05-07 11:18:22.690645 |
description | Deserialize environment variables into a struct |
homepage | |
repository | https://github.com/malobre/de_env |
max_upload_size | |
id | 578588 |
size | 26,147 |
de_env
helps you easily deserialize environment variables into a struct.
Assuming we have a TIMEOUT
, HOST
and RETRY
environment variable:
#[derive(serde::Deserialize, Debug)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
struct Config {
timeout: u16,
host: std::net::IpAddr,
retry: bool,
}
let config: Config = de_env::from_env()?;
println!("{config:#?}");