Function env_file_reader::read_file
source · [−]Expand description
Parses the environment file at the specified path
.
Returns an error if reading the file was unsuccessful or if the
file is ill-formatted.
Read the crate’s documentation for information about the
format that env-file-reader
supports.
Example:
examples/.env
:
CLIENT_ID=YOUR_CLIENT_ID
CLIENT_SECRET=YOUR_CLIENT_SECRET
use env_file_reader::read_file;
fn main() -> std::io::Result<()> {
let env_variables = read_file("examples/.env")?;
assert_eq!(&env_variables["CLIENT_ID"], "YOUR_CLIENT_ID");
assert_eq!(&env_variables["CLIENT_SECRET"], "YOUR_CLIENT_SECRET");
Ok(())
}