pub fn read_str(s: &str) -> Result<HashMap<String, String>, Error>
Expand description

Parses an environment file that is passed as a &str.

Returns an error if if the string is ill-formatted. Read the crate’s documentation for information about the format that env-file-reader supports.

Example:

use env_file_reader::read_str;

const ENV_FILE: &str = "
  CLIENT_ID=YOUR_CLIENT_ID
  CLIENT_SECRET=YOUR_CLIENT_SECRET
";

fn main() -> std::io::Result<()> {
  let env_variables = read_str(ENV_FILE)?;

  assert_eq!(&env_variables["CLIENT_ID"], "YOUR_CLIENT_ID");
  assert_eq!(&env_variables["CLIENT_SECRET"], "YOUR_CLIENT_SECRET");

  Ok(())
}