A type-safe Rust library for loading configuration from environment variables using derive macros.
[dependencies]
tryphon = "0.2.0"use tryphon::{Config,Secret};#[derive(Debug,Config)]structAppConfig{#[env("DATABASE_URL")]database_url:String,#[env("API_KEY")]api_key:Secret<String>,#[env("PORT")]#[default(8080)]port:u16,}matchAppConfig::load(){Ok(config) => {println!("Server starting on port {}", config.port);}Err(e) => {eprintln!("Configuration error: {}", e);}}#[test]#[env_vars(API_KEY = "qwerty",DATABASE_URL = "http://localhost:5432")]//override env vars for testfntest(){let config = AppConfig::load().expect("Failed to load test config");assert_eq!(*config.api_key,"qwerty");assert_eq!(config.database_url,"http://localhost:5432");assert_eq!(config.port,8080);}📚 Full Documentation on docs.rs
For detailed usage examples, supported types, and API reference, see the full documentation.
MIT License