de_env
Deserialize environment variables through serde.
You may be looking for:
Assuming we have a LOG
and PORT
environment variable:
```rust,no_run
struct Config { log: String, port: u16 }
let config: Config = deenv::fromenv().unwrap();
println!("{config:#?}"); ```
Boolean parsing is case-insensitive.
If the truthy-falsy
feature is enabled (default):
true
or its shorthand t
yes
or its shorthand y
on
1
false
or its shorthand f
no
or its shorthand n
off
0
If the truthy-falsy
feature is disabled, only true
and false
are
considered valid booleans.
Only unit variants can be deserialized.
Assuming we have a LEVEL
environment variable set to HIGH
, MEDIUM
or
LOW
:
```rust,no_run
enum Level { High, Medium, Low }
struct Pool { level: Level, }
let pool: Pool = deenv::fromenv().unwrap();
println!("{pool:#?}"); ```