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
use declarative_env;
;
;
/*
* #[derive(Debug, Clone)]
* pub struct ConfigWithPath {
* LOG_LEVEL: String,
* SERVER_PORT: u16,
* EMPTY_VALUE: String,
* REQUIRED_VALUE: i32,
* }
*
* impl ConfigWithPath {
* pub fn from_env() -> Result<Self, Box<dyn Error>> {
* // TODO: read env variable
* // if present, use the value,
* // if not present, use default value (try to parse it before inserting it plain)
* }
*
* pub fn LOG_LEVEL(&self) -> &str {
* &self.LOG_LEVEL
* }
*
* pub fn SERVER_PORT(&self) -> u16 {
* self.SERVER_PORT
* }
*
* pub fn EMPTY_VALUE(&self) -> &str {
* &self.EMPTY_VALUE
* }
*
* pub fn REQUIRED_VALUE(&self) -> i32 {
* self.REQUIRED_VALUE
* }
* }
*/