Skip to main content

Crate typed_env_vars

Crate typed_env_vars 

Source
Expand description

Typed Environment Variables

A type-safe environment variable library for Rust that provides automatic type conversion and validation.

§Features

  • Type Safety: Automatic type conversion with validation
  • Rich Types: Support for String, i32, i64, f64, bool, Vec, HashMap, URL
  • Default Values: Optional default values for missing variables
  • Clear Errors: Descriptive error messages for debugging
  • Zero Dependencies: No external dependencies required

§Examples

use typed_env_vars::EnvVar;
use std::env;

// Set environment variables for the example
env::set_var("API_KEY", "secret-key-123");

// Required string
let api_key = EnvVar::string("API_KEY").unwrap();

// Optional with default
let port = EnvVar::int("PORT").unwrap_or(8000);
let debug = EnvVar::bool("DEBUG").unwrap_or(false);

Structs§

EnvVar
Type-safe environment variable accessor

Enums§

EnvVarError
Error types for environment variable operations