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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
//! # config-lib - Multi-Format Configuration Library
//!
//! A high-performance configuration management library supporting multiple formats
//! including CONF, NOML, TOML, and JSON with advanced features like format preservation,
//! async operations, and schema validation.
//!
//! ## Quick Start
//!
//! ```rust
//! use config_lib::Config;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Parse any supported format automatically
//! let mut config = Config::from_string("port = 8080\nname = \"MyApp\"", None)?;
//!
//! // Access values with type safety
//! let port: i64 = config
//! .get("port")
//! .ok_or_else(|| config_lib::Error::key_not_found("port"))?
//! .as_integer()?;
//! let name: String = config
//! .get("name")
//! .ok_or_else(|| config_lib::Error::key_not_found("name"))?
//! .as_string()?
//! .to_owned();
//!
//! // Modify and save (preserves format and comments)
//! config.set("port", 9000)?;
//! # let _ = (port, name);
//! # Ok(())
//! # }
//! ```
//!
//! ## Supported Formats
//!
//! - **CONF** - Built-in parser for standard .conf files (default)
//! - **NOML** - Advanced configuration with dynamic features (feature: `noml`)
//! - **TOML** - Standard TOML format with format preservation (feature: `toml`)
//! - **JSON** - JSON format with edit capabilities (feature: `json`)
//!
//! ## Features
//!
//! - **High Performance** - Zero-copy parsing where possible
//! - **Format Preservation** - Maintains comments, whitespace, and formatting
//! - **Async Native** - Full async/await support (feature: `async`)
//! - **Schema Validation** - Type safety and validation (feature: `schema`)
//! - **Cross Platform** - Linux, macOS, and Windows support
//! - **Type Safety** - Rich type system with automatic conversions
// REPS — Rust Efficiency & Performance Standards (project-wide lint discipline).
// Shipping code MUST satisfy these denies; test code carries narrower
// allows with `REPS-AUDIT:` justifications where ergonomics outweigh the strict rule.
// REPS-AUDIT: `clippy::pedantic` is a curated lint group, not a hard rule.
// The following lints are turned back to `allow` because they fire on
// idioms this crate uses deliberately, or because they trade real
// readability against pure stylistic preference. The denies above
// (REPS safety / correctness rules) remain in force.
//
// Style / API-shape noise:
// Numeric casts at bounded parser/stats boundaries:
// Documentation style preference:
// Refactor suggestions deferred to a dedicated cleanup phase
// (see `.dev/ROADMAP.md` post-1.0 backlog):
// REPS-AUDIT: test modules use `.unwrap()` / `.expect()` / `panic!` for terse
// failure assertions, may emit `println!` / `eprintln!` for debug context,
// and use raw-string-with-hashes / direct float `==` / unseparated literals
// where the test input is more readable left as written. Allowed under
// `cfg(test)` only; never reachable in shipped binaries.
/// Enterprise-grade configuration management with advanced caching, performance optimizations,
/// and multi-instance support. Provides thread-safe caching with `Arc<RwLock>` for high-concurrency
/// environments and sub-50ns access times for cached values.
// Enterprise API with caching and performance
/// Hot reloading system for zero-downtime configuration updates
/// Comprehensive audit logging system for configuration operations
/// Environment variable override system for smart configuration overrides
// Re-export main types for convenience
pub use ;
// see `enterprise.rs` — the items themselves carry the deprecation notices
pub use ;
pub use ;
pub use Value;
pub use ;
pub use ;
use Path;
/// Parse configuration from a string with optional format hint
///
/// This is the primary entry point for parsing configuration data from strings.
/// Automatically detects format if not specified.
///
/// # Arguments
///
/// * `source` - The configuration data as a string
/// * `format` - Optional format hint ("conf", "toml", "json", "noml")
///
/// # Returns
///
/// Returns a [`Value`] containing the parsed configuration data.
///
/// # Errors
///
/// Returns an error if:
/// - The input format is unknown or unsupported
/// - The input contains syntax errors
/// - Required features are not enabled for the detected format
///
/// # Examples
///
/// ```rust
/// use config_lib::parse;
///
/// let config = parse("port = 8080\nname = \"MyApp\"", Some("conf"))?;
/// let port = config
/// .get("port")
/// .ok_or_else(|| config_lib::Error::key_not_found("port"))?
/// .as_integer()?;
/// # let _ = port;
/// # Ok::<(), config_lib::Error>(())
/// ```
/// Parse configuration from a file, auto-detecting format from extension
///
/// Reads a configuration file from disk and automatically detects the format
/// based on the file extension (.conf, .toml, .json, .noml).
///
/// # Arguments
///
/// * `path` - Path to the configuration file
///
/// # Returns
///
/// Returns a [`Value`] containing the parsed configuration data.
///
/// # Errors
///
/// Returns an error if:
/// - The file cannot be read (I/O error)
/// - The file format cannot be detected
/// - The file contains syntax errors
/// - Required features are not enabled for the detected format
///
/// # Examples
///
/// ```rust,no_run
/// use config_lib::parse_file;
///
/// let config = parse_file("app.conf")?;
/// let port = config
/// .get("server.port")
/// .ok_or_else(|| config_lib::Error::key_not_found("server.port"))?
/// .as_integer()?;
/// # let _ = port;
/// # Ok::<(), config_lib::Error>(())
/// ```
/// Validate configuration against a schema
///
/// Performs comprehensive validation of configuration data against a provided
/// schema definition.
///
/// # Arguments
///
/// * `config` - Configuration value to validate
/// * `schema` - Schema definition for validation
///
/// # Returns
///
/// Returns `Ok(())` if validation passes, or an error describing the issue.
///
/// # Examples
///
/// ```rust
/// # #[cfg(feature = "schema")]
/// # {
/// use config_lib::{parse, SchemaBuilder};
///
/// let config = parse(r#"
/// name = "my-app"
/// port = 8080
/// "#, None)?;
///
/// let schema = SchemaBuilder::new()
/// .require_string("name")
/// .require_integer("port")
/// .build();
///
/// config_lib::validate(&config, &schema)?;
/// # }
///
/// # Ok::<(), config_lib::Error>(())
/// ```
/// Async version of parse_file
///
/// Available when the `async` feature is enabled.
pub async