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
//! # prefer
//!
//! A lightweight library for managing application configurations with support for multiple file formats.
//!
//! `prefer` helps you manage application configurations while providing users the flexibility
//! of using whatever configuration format fits their needs.
//!
//! ## no_std Support
//!
//! This crate supports `no_std` environments with `alloc`. The core types (`ConfigValue`, `FromValue`,
//! `ValueVisitor`) work without std. Enable the `std` feature for file I/O, async loading, and format parsers.
//!
//! ## Features
//!
//! - **no_std compatible**: Core types work with just `alloc`
//! - **Format-agnostic**: Supports JSON, JSON5, YAML, TOML, INI, and XML (with `std`)
//! - **Automatic discovery**: Searches standard system paths for configuration files (with `std`)
//! - **Async by design**: Non-blocking operations for file I/O (with `std`)
//! - **File watching**: Monitor configuration files for changes (with `std`)
//! - **Dot-notation access**: Access nested values with `"auth.username"`
//! - **No serde required**: Uses a lightweight `FromValue` trait instead
//!
//! ## Examples
//!
//! ```no_run
//! # #[cfg(feature = "std")]
//! # {
//! use prefer::load;
//!
//! #[tokio::main]
//! async fn main() -> prefer::Result<()> {
//! // Load configuration from any supported format
//! let config = load("settings").await?;
//!
//! // Access values using dot notation
//! let username: String = config.get("auth.username")?;
//! println!("Username: {}", username);
//!
//! Ok(())
//! }
//! # }
//! ```
extern crate alloc;
// Core types (always available)
pub use ;
pub use ;
pub use ;
// std-dependent types
pub use ConfigBuilder;
pub use Config;
pub use ;
// Re-export the derive macro when the feature is enabled
pub use FromValue;
/// Load a configuration by identifier.
///
/// Routes through the plugin registry: finds a loader that can handle the
/// identifier, loads the raw content, finds a formatter that can parse
/// the content, and returns the parsed `Config`.
///
/// For bare names (e.g., `"myapp"`), the built-in `FileLoader` searches
/// standard system paths. For scheme-based identifiers (e.g.,
/// `"postgres://..."`), a `DbLoader` must be registered via inventory.
///
/// # Examples
///
/// ```no_run
/// # #[cfg(feature = "std")]
/// # {
/// use prefer::load;
///
/// #[tokio::main]
/// async fn main() -> prefer::Result<()> {
/// let config = load("myapp").await?;
/// let value: String = config.get("some.key")?;
/// Ok(())
/// }
/// # }
/// ```
pub async
/// Watch a configuration source for changes.
///
/// Routes through the plugin registry to find a loader that supports
/// watching, then returns a receiver that yields new `Config` instances
/// when the source changes.
///
/// # Examples
///
/// ```no_run
/// # #[cfg(feature = "std")]
/// # {
/// use prefer::watch;
///
/// #[tokio::main]
/// async fn main() -> prefer::Result<()> {
/// let mut receiver = watch("myapp").await?;
///
/// while let Some(config) = receiver.recv().await {
/// println!("Configuration updated!");
/// let value: String = config.get("some.key")?;
/// }
///
/// Ok(())
/// }
/// # }
/// ```
pub async