🦀 de_env

Deserialize environment variables through serde.


You may be looking for:

Example

Assuming we have a LOG and PORT environment variable:

```rust,no_run

[derive(serde::Deserialize, Debug)]

[serde(renameall = "SCREAMINGSNAKE_CASE")]

struct Config { log: String, port: u16 }

let config: Config = deenv::fromenv().unwrap();

println!("{config:#?}"); ```

Boolean parsing

Boolean parsing is case-insensitive.

If the truthy-falsy feature is enabled (default):

If the truthy-falsy feature is disabled, only true and false are considered valid booleans.

Enum

Only unit variants can be deserialized.

Assuming we have a LEVEL environment variable set to HIGH, MEDIUM or LOW:

```rust,no_run

[derive(serde::Deserialize, Debug)]

[serde(renameall = "SCREAMINGSNAKE_CASE")]

enum Level { High, Medium, Low }

[derive(serde::Deserialize, Debug)]

[serde(renameall = "SCREAMINGSNAKE_CASE")]

struct Pool { level: Level, }

let pool: Pool = deenv::fromenv().unwrap();

println!("{pool:#?}"); ```

Unsupported types