envie 0.1.0

Envie is a lightweight and user-friendly library for managing environment variables in Rust. It helps you load and parse .env files, retrieve variables with ease, and provides type-safe access to boolean and other data types.
Documentation
  • Coverage
  • 60%
    3 out of 5 items documented0 out of 5 items with examples
  • Size
  • Source code size: 22.36 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 228.7 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • LunaStev/Envie
    4 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • LunaStev

Envie

Envie is a lightweight and user-friendly library for managing environment variables in Rust. It allows you to load and parse .env files effortlessly and provides type-safe access to environment variables for seamless integration into your applications.

Key Features

  • Automatically loads .env files
  • Retrieves environment variables by key
  • Supports type-safe conversions (e.g., boolean, integers)
  • Fallback to system environment variables

Installation

Add Envie to your Cargo.toml file:

envie = "0.1.0"

Then run:

cargo build

Usage

Here’s a quick example of how to use Envie:

Load environment variables

use envie::Envie;

fn main() {
let env = Envie::load().expect("Failed to load .env file");

    let database_url = env.get("DATABASE_URL").unwrap_or_else(|| "default_url".to_string());
    let debug_mode: bool = env.get_bool("DEBUG_MODE").unwrap_or(false);

    println!("Database URL: {}", database_url);
    println!("Debug Mode: {}", debug_mode);
}

Example .env file

DATABASE_URL=postgres://user:password@localhost:5432/mydb
DEBUG_MODE=true

Why Envie?

Envie makes managing environment variables simple and intuitive while maintaining Rust's type safety and performance standards. Whether you’re working on small projects or large-scale applications, Envie ensures your configuration is accessible and reliable.

License

This project is licensed under the MPL-2.0 License. See the LICENSE file for details.