Expand description
§mytheclipse-config
A type-safe, dynamic configuration engine: load environment variables,
.env files, YAML, JSON, or TOML directly into a typed Rust struct, with
optional runtime hot-reload.
ConfigLoadermerges any number of file/env sources into a single typed value (files first, environment variables override).DynamicConfigwraps a loaded value behind anRwLock, optionally watching its source files and swapping in a freshly reloaded value when they change, broadcasting the change to subscribers.
§Example
use serde::Deserialize;
use mytheclipse_config::ConfigLoader;
#[derive(Debug, Deserialize, Clone)]
struct AppConfig {
port: u16,
database: DatabaseConfig,
}
#[derive(Debug, Deserialize, Clone)]
struct DatabaseConfig {
url: String,
}
let config: AppConfig = ConfigLoader::new()
.merge_file("config.yaml".as_ref())
.unwrap()
.merge_env("APP")
.build()
.unwrap();Re-exports§
pub use error::ConfigError;pub use loader::ConfigLoader;pub use validate::collect_failures;pub use validate::validate_non_empty;pub use validate::validate_port;pub use validate::validate_range;pub use validate::validate_url;pub use validate::ConfigValidator;pub use validate::ConfigValidatorExt;pub use validate::ValidationError;pub use validate::ValidationFailure;pub use dynamic::DynamicConfig;
Modules§
- dynamic
- Runtime configuration hot-reload (feature
hot-reload). - error
- Shared error type for mytheclipse-config.
- loader
- Merges file and environment sources into a typed configuration value.
- validate
- Config validation traits and built-in validators (feature
validation).
Traits§
- Config
- Marker trait for types loadable by
ConfigLoader.