Expand description
§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
FromValuetrait instead
§Examples
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(())
}Re-exports§
pub use error::Error;pub use error::Result;pub use value::ConfigValue;pub use value::FromValue;pub use visitor::SeqAccess;pub use visitor::ValueVisitor;pub use builder::ConfigBuilder;pub use config::Config;pub use source::EnvSource;pub use source::FileSource;pub use source::LayeredSource;pub use source::MemorySource;pub use source::Source;
Modules§
- builder
- Configuration builder for composing multiple sources.
- 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.
- source
- Configuration source abstraction.
- value
- Configuration value types and conversion traits.
- visitor
- Visitor pattern for configuration value traversal.
- watch
- File watching functionality for configuration files.