Skip to main content

Crate ch_config

Crate ch_config 

Source
Expand description

§ch-config

Typed configuration for Rust apps.

§Installation

[dependencies]
ch-config = "0.2.0"

Requires Rust 1.99 or newer.

§Usage

load_app_config applies environment values to your defaults and returns a shared AppConfig. It supports MariaDB, SpacetimeDB, media storage, CAPTCHA, and email settings.

Values can come from environment variables or secret files. Use DATABASE_URL or DATABASE_URL_FILE to choose one source. Supplying both returns an error.

environment::value reads individual application settings. environment::public_url reads and checks PUBLIC_URL.

§Dotenv files

environment::EnvFiles::load builds one configuration snapshot for the process. The base file supplies defaults. Process variables take priority over the base file. The override file takes priority over both.

Read loaded settings through environment::value, environment::var, or load_app_config. Loading does not change the OS environment and is safe after threads have started. Failed loads leave the configuration unchanged.

Load the files once during startup. Repeating the same selection keeps the existing snapshot. Pass environment::vars_os() to Command::envs when a child process needs the loaded settings.

See the API documentation for available settings.

§License

Sustainable Use License 1.0.

Re-exports§

pub use config::AppConfig;
pub use config::ConfigError;
pub use config::EnvironmentFileError;
pub use config::Result;

Modules§

config
Typed configuration sections, environment resolution, and validation.
environment
Process-environment and dotenv-file loading for application startup.

Functions§

load_app_config
Applies deployment environment values to stable defaults, validates the result, and shares the resolved configuration.