Skip to content

dryrust/getenv.rs

Repository files navigation

Getenv.rs

License Compatibility Package Documentation

🚧 We are building in public. This is presently under heavy construction.

✨ Features

  • Implements a comprehensive set of environment variable getters for various platforms, programming languages, and tools.
  • Provides a wide range of varsets (variable sets), including for: AWS, Cargo, Conda, CUDA, Docker, Git, Go, Homebrew, Java, Locale, macOS, NEAR, Node.js, OpenSSL, POSIX, Proxy, Python, Ruby, Rust, SSH, Windows, and XDG.
  • Protects sensitive environment variables (such as API keys) by preventing their accidental copying, logging, or other exposure, and securely wiping them from memory when dropped.
  • Treats empty environment variables the same as missing ones.
  • Supports opting out of any feature using comprehensive feature flags.
  • Adheres to the Rust API Guidelines in its naming conventions.
  • 100% free and unencumbered public domain software.

🛠️ Prerequisites

⬇️ Installation

Installation via Cargo

cargo add getenv

Installation in Cargo.toml (with all features enabled)

[dependencies]
getenv = "0.1"

Installation in Cargo.toml (with only specific features enabled)

[dependencies]
getenv = { version = "0.1", default-features = false, features = ["posix"] }

👉 Examples

Importing the library

use getenv::*;

Reading environment variables

use getenv::aws::*;

println!("AWS_ACCESS_KEY_ID={:?}", aws_access_key_id());
println!("AWS_SECRET_ACCESS_KEY={:?}", aws_secret_access_key());

📚 Reference

Varset Feature Reference
aws aws use getenv::aws::*;
cargo cargo use getenv::cargo::*;
conda conda use getenv::conda::*;
cuda cuda use getenv::cuda::*;
docker docker use getenv::docker::*;
git git use getenv::git::*;
go go use getenv::go::*;
homebrew homebrew use getenv::homebrew::*;
java java use getenv::java::*;
locale locale use getenv::locale::*;
macos macos use getenv::macos::*;
near near use getenv::near::*;
node node use getenv::node::*;
openssl openssl use getenv::openssl::*;
posix posix use getenv::posix::*;
proxy proxy use getenv::proxy::*;
python python use getenv::python::*;
ruby ruby use getenv::ruby::*;
rust rust use getenv::rust::*;
ssh ssh use getenv::ssh::*;
windows windows use getenv::windows::*;
xdg xdg use getenv::xdg::*;

Integrations

Crate (Feature) Version Usage Summary
miette  ("miette") 7.5 miette Enhances dogma::{IriError, UriError}
serde  ("serde") 1 serde Derives serde::{Serialize, Deserialize}
 

👨‍💻 Development

git clone https://github.com/dryrust/getenv.rs.git

Share on X Share on Reddit Share on Hacker News Share on Facebook Share on LinkedIn