CI / Rustfmt (push) Canceled after 0s
CI / Clippy (push) Canceled after 0s
CI / Test (workspace all features) (push) Canceled after 0s
CI / Test (workspace default features) (push) Canceled after 0s
CI / Test (mytheclipse / bg only) (push) Canceled after 0s
CI / Test (mytheclipse / compute only) (push) Canceled after 0s
CI / Test (mytheclipse / io only) (push) Canceled after 0s
CI / Test (mytheclipse / lifecycle only) (push) Canceled after 0s
CI / Test (mytheclipse / observability only) (push) Canceled after 0s
CI / Test (mytheclipse / resiliency only) (push) Canceled after 0s
CI / Test (mytheclipse / traffic only) (push) Canceled after 0s
CI / Test (mytheclipse-cache / l2-redis) (push) Canceled after 0s
CI / Test (mytheclipse-cache / l1-moka) (push) Canceled after 0s
CI / Test (mytheclipse-cache / default) (push) Canceled after 0s
CI / Test (mytheclipse-config / default) (push) Canceled after 0s
CI / Test (mytheclipse-crypto / default) (push) Canceled after 0s
CI / Test (mytheclipse-event / amqp) (push) Canceled after 0s
CI / Test (mytheclipse-event / nats) (push) Canceled after 0s
CI / Test (mytheclipse-event / default (mem)) (push) Canceled after 0s
CI / Test (mytheclipse-storage / gcs) (push) Canceled after 0s
CI / Test (mytheclipse-storage / s3) (push) Canceled after 0s
CI / Test (mytheclipse-storage / default (local)) (push) Canceled after 0s
CI / Run mytheclipse example (push) Canceled after 0s
CI / Docs check (push) Canceled after 0s
CI / Cargo package dry-run (mytheclipse) (push) Canceled after 0s
CI / Cargo package dry-run (mytheclipse-cache) (push) Canceled after 0s
CI / Cargo package dry-run (mytheclipse-config) (push) Canceled after 0s
CI / Cargo package dry-run (mytheclipse-crypto) (push) Canceled after 0s
CI / Cargo package dry-run (mytheclipse-event) (push) Canceled after 0s
CI / Cargo package dry-run (mytheclipse-storage) (push) Canceled after 0s
Release / Semantic Release (push) Canceled after 0s
Rename all `corex-cache`, `corex-storage`, `corex-event`, `corex-config`, and `corex-crypto` crates to `mytheclipse-cache`, `mytheclipse-storage`, `mytheclipse-event`, `mytheclipse-config`, and `mytheclipse-crypto` respectively, aligning with the `mytheclipse` root crate naming convention. - Convert root `Cargo.toml` from a package manifest to a workspace manifest with explicit member paths - Update crate names in each `Cargo.toml` and docs.rs URLs - Update all import paths, module doc comments, and error/panic messages from `corex-*` to `mytheclipse-*` across source and README files - Update CI workflow and publish script to reference the new crate names<tool_call></think>chore: rename corex-* crates to mytheclipse-* namespace Rename all `corex-cache`, `corex-storage`, `corex-event`, `corex-config`, and `corex-crypto` crates to `mytheclipse-cache`, `mytheclipse-storage`, `mytheclipse-event`, `mytheclipse-config`, and `mytheclipse-crypto` respectively, aligning with the `mytheclipse` root crate naming convention. - Convert root `Cargo.toml` from a package manifest to a workspace manifest with explicit member paths - Update crate names in each `Cargo.toml` and docs.rs URLs - Update all import paths, module doc comments, and error/panic messages from `corex-*` to `mytheclipse-*` across source and README files - Update CI workflow and publish script to reference the new crate names
54 lines
1.6 KiB
Rust
54 lines
1.6 KiB
Rust
//! # 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.
|
|
//!
|
|
//! - [`ConfigLoader`] merges any number of file/env sources into a single
|
|
//! typed value (files first, environment variables override).
|
|
//! - [`DynamicConfig`] wraps a loaded value behind an `RwLock`, optionally
|
|
//! watching its source files and swapping in a freshly reloaded value when
|
|
//! they change, broadcasting the change to subscribers.
|
|
//!
|
|
//! ## Example
|
|
//!
|
|
//! ```no_run
|
|
//! 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();
|
|
//! ```
|
|
|
|
pub mod error;
|
|
pub mod loader;
|
|
|
|
#[cfg(feature = "hot-reload")]
|
|
pub mod dynamic;
|
|
|
|
pub use error::ConfigError;
|
|
pub use loader::ConfigLoader;
|
|
|
|
#[cfg(feature = "hot-reload")]
|
|
pub use dynamic::DynamicConfig;
|
|
|
|
/// Marker trait for types loadable by [`ConfigLoader`].
|
|
///
|
|
/// Blanket-implemented for any `Deserialize + Send + Sync + 'static`.
|
|
pub trait Config: for<'de> serde::Deserialize<'de> + Send + Sync + 'static {}
|
|
impl<T> Config for T where T: for<'de> serde::Deserialize<'de> + Send + Sync + 'static {}
|