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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//! This crate provides a configuration loader in the style of the [ruby dotenv
//! gem](https://github.com/bkeepers/dotenv). This library is meant to be used
//! on development or testing environments in which setting environment
//! variables is not practical. It loads environment variables from a .env
//! file, if available, and mashes those with the actual environment variables
//! provided by the operating system.
use ;
use OsStr;
use File;
use ;
use Once;
pub use crate*;
use crateFinder;
use crateIter;
static START: Once = new;
/// After loading the dotenv file, fetches the environment variable key from the current process.
///
/// The returned result is Ok(s) if the environment variable is present and is valid unicode. If the
/// environment variable is not present, or it is not valid unicode, then Err will be returned.
///
/// Examples:
///
/// ```no_run
///
/// use dotenv_flow;
///
/// let key = "FOO";
/// let value= dotenv_flow::var(key).unwrap();
/// ```
/// After loading the dotenv file, returns an iterator of (variable, value) pairs of strings,
/// for all the environment variables of the current process.
///
/// The returned iterator contains a snapshot of the process's environment variables at the
/// time of this invocation, modifications to environment variables afterwards will not be
/// reflected in the returned iterator.
///
/// Examples:
///
/// ```no_run
///
/// use dotenv_flow;
/// use std::io;
///
/// let result: Vec<(String, String)> = dotenv_flow::vars().collect();
/// ```
/// Loads the file at the specified absolute path.
///
/// Examples
///
/// ```
/// use dotenv_flow;
/// use std::env;
/// use std::path::{Path};
///
/// let my_path = env::home_dir().and_then(|a| Some(a.join("/.env"))).unwrap();
/// dotenv_flow::from_path(my_path.as_path());
/// ```
/// Like `from_path`, but returns an iterator over variables instead of loading into environment.
///
/// Examples
///
/// ```no_run
/// use dotenv_flow;
/// use std::env;
/// use std::path::{Path};
///
/// let my_path = env::home_dir().and_then(|a| Some(a.join("/.env"))).unwrap();
/// let iter = dotenv_flow::from_path_iter(my_path.as_path()).unwrap();
///
/// for item in iter {
/// let (key, val) = item.unwrap();
/// println!("{}={}", key, val);
/// }
/// ```
/// Loads the specified file from the environment's current directory or its parents in sequence.
///
/// # Examples
/// ```
/// use dotenv_flow;
/// dotenv_flow::from_filename("custom.env").ok();
/// ```
///
/// It is also possible to do the following, but it is equivalent to using `dotenv_flow::dotenv()`,
/// which is preferred.
///
/// ```
/// use dotenv_flow;
/// dotenv_flow::from_filename(".env").ok();
/// ```
/// Like `from_filename`, but returns an iterator over variables instead of loading into environment.
///
/// # Examples
/// ```
/// use dotenv_flow;
/// dotenv_flow::from_filename("custom.env").ok();
/// ```
///
/// It is also possible to do the following, but it is equivalent to using `dotenv_flow::dotenv()`,
/// which is preferred.
///
/// ```no_run
/// use dotenv_flow;
/// let iter = dotenv_flow::from_filename_iter(".env").unwrap();
///
/// for item in iter {
/// let (key, val) = item.unwrap();
/// println!("{}={}", key, val);
/// }
/// ```
/// This is usually what you want.
/// It loads the .env file located in the environment's current directory or its parents in sequence.
///
/// # Examples
/// ```
/// use dotenv_flow;
/// dotenv_flow::dotenv().ok();
/// ```
/// Similar to dotenv, but implements the dotenv-flow strategy by loading multiple `.env`s following
/// the order determined by their suffixes.
///
/// The strategy is as follows:
/// - if a DOTENV_ENV environment variable is set, load .env.{DOTENV_ENV}.local (e.g. .env.staging.local)
/// - load .env.local
/// - if a DOTENV_ENV environment variable is set, load .env.{DOTENV_ENV} (e.g. .env.staging)
/// - load .env
///
/// # Examples
/// ```
/// use dotenv_flow;
/// dotenv_flow::dotenv_flow().ok();
/// ```
/// Like `dotenv`, but returns an iterator over variables instead of loading into environment.
///
/// # Examples
/// ```no_run
/// use dotenv_flow;
///
/// for item in dotenv_flow::dotenv_iter().unwrap() {
/// let (key, val) = item.unwrap();
/// println!("{}={}", key, val);
/// }
/// ```