ch-config 0.1.0

Typed configuration loading with validation and secret-file support
Documentation
ch-config-0.1.0 has been yanked.

ch-config

ch-config loads typed runtime configuration from explicit defaults, environment variables, and optional secret files.

More information is available in the API documentation.

High-level features

  • Typed configuration sections with validation
  • Direct environment values or mutually exclusive _FILE companions
  • Explicit dotenv loading with predictable precedence
  • Redacted diagnostics for credentials and secret-bearing URLs
  • No application discovery or repository-layout assumptions

AppConfig includes optional MariaDB, SpacetimeDB, media-library, CAPTCHA, and email sections. Applications provide stable defaults in code; deployment values come from the process environment.

Usage

use std::sync::Arc;

use ch_config::{
    config::{AppConfig, CaptchaConfig, EmailConfig},
    load_app_config,
};

fn load() -> ch_config::config::Result<Arc<AppConfig>> {
    load_app_config(AppConfig {
        captcha: CaptchaConfig::standard(),
        email: EmailConfig::mailersend("sender@example.com", "Example"),
        ..AppConfig::default()
    })
}

Supported environment families include DATABASE_*, Railway's MYSQL* connection values, SPACETIMEDB_*, MEDIA_LIBRARY_*, CAPTCHA_*, EMAIL_*, and SMTP_*. Every supported value also accepts an _FILE companion such as DATABASE_URL_FILE.

Dotenv files

Environment files are opt-in and loaded only from the supplied paths. The base file fills missing process variables; the override file replaces values and is intended for local development.

use ch_config::environment::EnvFiles;

# fn load(base: std::path::PathBuf, local: std::path::PathBuf) -> Result<(), Box<dyn std::error::Error>> {
EnvFiles {
    base: Some(base),
    override_file: Some(local),
}
.load()?;
# Ok(())
# }

environment::value exposes the same direct-or-file resolution for application-owned settings. environment::public_url validates and normalizes the conventional PUBLIC_URL value.

Minimum supported Rust version

ch-config requires Rust 1.96 or newer.

License

Licensed under the Sustainable Use License 1.0. See LICENSE.md.