Expand description
§prefer
A 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. It automatically discovers
configuration files in standard system locations and supports JSON, JSON5, YAML, TOML,
INI, and XML formats.
§Features
- Format-agnostic: Supports JSON, JSON5, YAML, TOML, INI, and XML
- Automatic discovery: Searches standard system paths for configuration files
- Async by design: Non-blocking operations for file I/O
- File watching: Monitor configuration files for changes
- Dot-notation access: Access nested values with
"auth.username" - Cross-platform: Works on Linux, macOS, and Windows
§Examples
use prefer::load;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Load configuration from any supported format
let config = load("settings").await?;
// Access values using dot notation
let username: String = config.get("auth.username").await?;
println!("Username: {}", username);
Ok(())
}Re-exports§
pub use config::Config;pub use config::ConfigValue;pub use error::Error;pub use error::Result;
Modules§
- config
- Core configuration types and methods.
- discovery
- Configuration file discovery across standard system paths.
- error
- Error types for the prefer library.
- formats
- Configuration file format parsers.
- watch
- File watching functionality for configuration files.