Expand description
§Toxi Config
Configuration and environment variable management for Toxi applications.
Loads toxi.toml with support for typed config sections, flat [env] tables,
namespaced tables, nested overrides, and .env file loading.
§Environment Variable Naming — Fully Flexible
No env var names are forced. The framework adapts to whatever you configure. You choose the names; Toxi reads them.
§Framework Defaults (override in toxi.toml)
| Env Var | Purpose | Default |
|---|---|---|
TOXI_ENV | App environment | development |
TOXI_SKIP_DOTENV | Skip .env loading | (unset) |
§User-Configurable (set in toxi.toml or .env)
These have sensible defaults — none are required:
| Env Var | Config Key | Default |
|---|---|---|
DATABASE_URL | [database] url | "" |
REDIS_URL | [cache] redis_url | "" |
JWT_SECRET | [security] jwt_secret | "" |
SERVER_HOST | [server] host | 127.0.0.1 |
SERVER_PORT | [server] port | 3000 |
§Custom Names via [env] Table
Define your own env var names in toxi.toml:
[env]
MY_DB_URL = "postgres://localhost/myapp"
MY_API_KEY = "secret-123"Or use namespaced tables for auto-derived names:
[database]
url = "postgres://localhost/myapp" # becomes DATABASE_URL
[my_service]
api_key = "secret" # becomes MY_SERVICE_API_KEY§Resolution Order (highest to lowest priority)
- Real OS environment variables
.envfile entries[env]flat table entries- Known sections (
[server],[database], etc.) - Custom namespaced tables
§Quick Start
use toxi_config::Config;
let config = Config::load()
.map_err(|e| eprintln!("config error: {e}")).unwrap();
let host: String = config.get("server.host")
.unwrap_or_else(|| "127.0.0.1".to_string());
println!("Server: {host}");Structs§
- AppConfig
- Application metadata configuration
- Cache
Config - Cache driver configuration (memory or Redis)
- Config
- Root configuration struct representing an
toxi.tomlfile - Database
Config - Database connection configuration
- Queue
Config - Background job queue configuration
- Security
Config - Security configuration (JWT, CORS, rate limiting)
- Server
Config - HTTP server configuration (host, port, worker count)
Enums§
- Config
Error - Errors that can occur during configuration loading and parsing
- Environment
- Application environment mode