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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
//! Configuration file discovery and reading with multiple format support.
//!
//! **DEPRECATED**: This crate is deprecated since version 2.0.1.
//! Use `cfgmatic-source` instead, which provides a more comprehensive
//! and unified API for configuration source management.
//!
//! # Migration Guide
//!
//! This crate has been superseded by `cfgmatic-source`. Below is a guide
//! for migrating your code to the new API.
//!
//! ## Crate Replacement
//!
//! Replace in `Cargo.toml`:
//! ```toml
//! // Old (deprecated)
//! [dependencies]
//! cfgmatic-files = "2.0"
//!
//! // New
//! [dependencies]
//! cfgmatic-source = "2.0"
//! ```
//!
//! ## Type Mappings
//!
//! | Old (cfgmatic-files) | New (cfgmatic-source) | Notes |
//! |----------------------|----------------------|-------|
//! | `ConfigFile` | `FileSource` | File-based configuration source |
//! | `ConfigFiles` | `CompositeSource` | Multiple sources with priority |
//! | `FileFinder` | `Loader` with `FileConfig` | Unified loading interface |
//! | `Mergeable` | `Merge` trait from `cfgmatic-merge` | Direct merge trait |
//! | `Format` | `cfgmatic_source::Format` | Same enum, new location |
//! | `FileError` | `SourceError` | Unified error type |
//!
//! ## API Examples
//!
//! ### Loading a Single File
//!
//! ```rust,ignore
//! // Old API (deprecated)
//! use cfgmatic_files::FileFinder;
//! let files = FileFinder::new("myapp").find()?;
//! let config: Config = files.first().unwrap().parse()?;
//!
//! // New API
//! use cfgmatic_source::prelude::*;
//! let config: Config = FileSource::new("config.toml").load()?.parse_as()?;
//! ```
//!
//! ### Loading with Multiple Sources
//!
//! ```rust,ignore
//! // Old API (deprecated)
//! use cfgmatic_files::load_merged;
//! let config: Config = load_merged("myapp")?;
//!
//! // New API
//! use cfgmatic_source::prelude::*;
//! let source = CompositeSource::new()
//! .with_source(FileSource::new("config.toml"), SourcePriority::High)
//! .with_source(EnvSource::new("APP"), SourcePriority::Low);
//! let config: Config = source.load()?.parse_as()?;
//! ```
//!
//! ### Finding Config Files
//!
//! ```rust,ignore
//! // Old API (deprecated)
//! use cfgmatic_files::{FileFinder, find_files};
//! let files = find_files("myapp")?;
//!
//! // New API
//! use cfgmatic_source::prelude::*;
//! let loader = Loader::new()
//! .with_source(FileConfig::new().app_name("myapp"));
//! let result = loader.load()?;
//! ```
//!
//! # Features
//!
//! The new `cfgmatic-source` crate supports all features from this crate:
//!
//! - `toml` - TOML format support (default)
//! - `json` - JSON format support (default)
//! - `yaml` - YAML format support
//! - `env` - Environment variable sources
//! - `async` - Async loading support
//! - `remote` - Remote HTTP/HTTPS sources
//! - `watch` - File watching support
//!
//! # Transition Period
//!
//! During the transition period, this crate re-exports types from
//! `cfgmatic-source` for convenience. However, new code should use
//! `cfgmatic-source` directly.
// Deprecated crate - allow all pedantic lints and deprecated usage internally
// =============================================================================
// Re-exports from cfgmatic-source (new API)
// =============================================================================
/// Re-export of cfgmatic-source types for migration convenience.
pub use ;
// Feature-gated re-exports from cfgmatic-source
pub use FileSource;
// =============================================================================
// Legacy types (deprecated but kept for backwards compatibility)
// =============================================================================
// Legacy module
pub use ;
pub use ;
pub use ;
pub use Format;
pub use ;
pub use ;
// Re-export from cfgmatic-paths for convenience (legacy)
pub use ;
/// Convenience functions for common operations.
///
/// **Deprecated**: Use `cfgmatic_source::prelude` instead.
/// Load and merge configuration from all found files.
///
/// **Deprecated**: Use `cfgmatic_source::Loader` instead.
///
/// # Example
///
/// ```
/// use cfgmatic_files::load_merged;
///
/// match load_merged::<serde_json::Value>("myapp") {
/// Ok(config) => println!("Loaded: {:?}", config),
/// Err(e) => eprintln!("Failed to load config: {}", e),
/// }
/// ```
///
/// # Errors
///
/// Returns an error if directories cannot be accessed or files cannot be parsed.
/// Find configuration files with a specific format.
///
/// **Deprecated**: Use `cfgmatic_source::Loader` with `FileConfig` instead.
///
/// # Example
///
/// ```
/// use cfgmatic_files::find_with_format;
///
/// let files = find_with_format("myapp", cfgmatic_files::Format::Toml)
/// .expect("find toml files");
/// ```
///
/// # Errors
///
/// Returns an error if directories cannot be accessed.
/// Check if a configuration exists for the application.
///
/// Returns `true` if at least one configuration file is found.