1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! # `de_env`
//!
//! _**De**serialize **env**ironment variables into a struct._
//!
//! ---
//!
//! You may be looking for:
//!
//! - [Git repository](https://github.com/malobre/de_env)
//! - [Crates.io](https://crates.io/crates/de_env)
//!
//! ## Example
//!
//! Assuming we have a `TIMEOUT` and `HOST` environment variable:
//!
//! ```rust
//! #[derive(serde::Deserialize, Debug)]
//! #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
//! struct Config {
//! timeout: u16,
//! host: std::net::IpAddr,
//! }
//!
//! # std::env::set_var("TIMEOUT", "12");
//! # std::env::set_var("HOST", "127.0.0.1");
//! let config: Config = de_env::from_env()?;
//!
//! println!("{config:#?}");
//! # Ok::<(), de_env::Error>(())
//! ```
//!
//! ## Supported Primitives
//!
//! - String slices
//! - Chars
//! - Numbers (parsed with their respective [`FromStr`](std::str::FromStr) implementations)
//! - Booleans (see [boolean parsing](#boolean-parsing))
//!
//! ## Boolean Parsing
//!
//! **Boolean parsing is case-insensitive.**
//!
//! If the `truthy-falsy` feature is enabled (default):
//!
//! - Truthy values:
//! - `true` or its shorthand `t`
//! - `yes` or its shorthand `y`
//! - `on`
//! - `1`
//! - Falsy values:
//! - `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.
//!
//! ## Enums
//!
//! **Only unit variants can be deserialized.**
//!
//! Assuming we have a `LOG_LEVEL` environment variable set to `INFO` or `WARN`:
//!
//! ```rust
//! #[derive(serde::Deserialize, Debug)]
//! #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
//! enum Level {
//! Info,
//! Warn
//! }
//!
//! #[derive(serde::Deserialize, Debug)]
//! #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
//! struct Config {
//! log_level: Level,
//! }
//!
//! # std::env::set_var("LOG_LEVEL", "INFO");
//! let config: Config = de_env::from_env()?;
//!
//! println!("{config:#?}");
//! # Ok::<(), de_env::Error>(())
//! ```
//!
//! ## Unsupported Types
//!
//! The goal of this crate is to deserialize environment variables into a **struct**, no other type
//! is supported at top level. Custom types must be able to deserialize from [supported primitives].
//!
//! [supported primitives]: #supported-primitives
pub use ;
pub use ;