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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! A library for managing and loading application settings from multiple sources.
//!
//! This library provides functionality to load and merge configuration values from
//! various sources such as configuration files (JSON, TOML, YAML, HJSON, RON),
//! environment variables, command-line arguments, and secret management systems.
//!
//! # Features
//! - Supports multiple configuration file formats (JSON, TOML, YAML, HJSON, RON).
//! - Merges configuration from multiple sources, with precedence rules (CLI > Env Vars > File).
//! - Strongly typed access to configuration values.
//! - Easily extendable to add more configuration sources.
//!
//! # Usage
//! ```rust, ignore
//! use std::path::PathBuf;
//! use serde::{Serialize, Deserialize};
//! use clap::Parser;
//! use settings_loader::{Environment, SettingsLoader, LoadingOptions, SettingsError};
//! use settings_loader::common::database::DatabaseSettings;
//!
//! pub struct ApplicationSettings { ... }
//!
//! #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
//! struct MySettings {
//! pub application: ApplicationSettings,
//! pub database: DatabaseSettings,
//! }
//!
//! impl SettingsLoader for MySettings {
//! type Options = CliOptions;
//! }
//!
//! struct CliOptions {
//! config: Option<PathBuf>,
//! secrets: Option<PathBuf>,
//! environment: Option<Environment>,
//! }
//!
//! impl LoadingOptions for CliOptions {
//! type Error = SettingsError;
//!
//! fn config_path(&self) -> Option<PathBuf> {
//! self.config.clone()
//! }
//!
//! fn secrets_path(&self) -> Option<PathBuf> {
//! self.secrets.clone()
//! }
//!
//! fn implicit_search_paths(&self) -> Vec<PathBuf> {
//! vec![PathBuf::from("./config")]
//! }
//! }
//!
//! fn main() -> anyhow::Result<()> {
//! ...
//! let options = CliOptions::parse()?;
//! let settings = MySettings::load(&options)?;
//!
//! // Use settings...
//! }
//! ```
pub use Environment;
pub use SettingsError;
pub use ;
pub use ;
pub use ConfigScope;
pub use SettingsLoader;
pub use crate;
pub use crate;
pub use ;