1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! # Dyson Boot
//!
//! A convenient Rust crate for quickly bootstrapping application configuration with minimal boilerplate.
//!
//! ## Features
//!
//! - Zero-boilerplate configuration loading with a simple macro
//! - Multi-source configuration (files + environment variables)
//! - Thread-safe singleton pattern with lazy initialization
//! - Type-safe deserialization using `serde`
//! - Environment variable override support
//!
//! ## Quick Example
//!
//! ```rust,no_run
//! use dyson_boot::settings_struct;
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Debug, Clone, Deserialize, Serialize)]
//! struct AppConfig {
//! pub host: String,
//! pub port: u16,
//! pub debug: bool,
//! }
//!
//! // Generate configuration loader with defaults
//! settings_struct!(AppConfig);
//!
//! fn main() {
//! // Access configuration anywhere in your app
//! let config = get_app_config();
//! println!("Server running on {}:{}", config.host, config.port);
//! }
//! ```
//!
//! ## How It Works
//!
//! The `settings_struct!` macro generates:
//! 1. A `load()` method that reads configuration from files and environment variables
//! 2. A thread-safe static instance using `once_cell::Lazy`
//! 3. A getter function `get_{struct_name}()` that returns an `Arc<YourConfig>`
//!
//! The configuration is loaded lazily on first access and cached for the application lifetime.
//!
//! ## Configuration Priority
//!
//! Values are loaded in this order (later sources override earlier ones):
//! 1. Configuration file (JSON, TOML, YAML, etc.)
//! 2. Environment variables with the specified prefix
//!
//! See the [`settings_struct`] macro documentation for more details.
/// Settings module
// ///
// /// Contains helpers and types for loading and managing application configuration:
// /// - `settings_struct!` macro generated loader for typed config
// /// - Multi-source loading (files + environment) with override precedence
// /// - Thread-safe cached instance for global access