Skip to content

Repository files navigation

Tryphon

A type-safe Rust library for loading configuration from environment variables using derive macros.

Crates.ioDocumentation

Installation

[dependencies]
tryphon = "0.2.0"

Quick Example

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);}

Documentation

📚 Full Documentation on docs.rs

For detailed usage examples, supported types, and API reference, see the full documentation.

License

MIT License

About

Type-safe config env variables loader for Rust

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages