<h1 align="center">
<img width="90px" height="auto" src="https://raw.githubusercontent.com/jamesgober/jamesgober/main/media/icons/hexagon-3.svg" alt="Triple Hexagon">
<br>
<b>confi| **0.5.x** | ๐ง API expansion & additional functionality | Released |
| **0.6.x** | ๐ก๏ธ API finalization & bulletproofing | **Current** |lib</b>
</h1>
<p align="center">
<b>๐ Enterprise-Grade Multi-Format Configuration Library</b>
<br>
<i>High-performance configuration management with advanced caching, validation, and format preservation</i>
</p>
<p align="center">
<a href="https://crates.io/crates/config-lib"><img src="https://img.shields.io/crates/v/config-lib.svg" alt="Crates.io"></a>
<a href="https://docs.rs/config-lib"><img src="https://docs.rs/config-lib/badge.svg" alt="Documentation"></a>
<a href="https://github.com/jamesgober/config-lib/actions"><img src="https://github.com/jamesgober/config-lib/workflows/CI%2FCD/badge.svg" alt="CI Status"></a>
<a href="https://github.com/jamesgober/config-lib/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License"></a>
</p>
---
## ๐ Features
### ๐ **Multi-Format Support**
- **CONF** - Built-in parser for standard .conf files (default)
- **INI** - Full INI file parsing with sections, comments, and data type detection
- **JSON** - JSON format with edit capabilities and serialization
- **XML** - Zero-copy XML parsing with quick-xml for Java/.NET environments
- **HCL** - HashiCorp Configuration Language for DevOps workflows
- **Properties** - Complete Java .properties file parsing with Unicode and escaping
- **NOML** - Advanced configuration with dynamic features (feature: `noml`)
- **TOML** - TOML format with format preservation (feature: `toml`)
### โก **Enterprise Performance**
- **Sub-50ns Cache Access** - Multi-tier caching achieving 24.9ns average (50% better than 50ns target)
- **Zero-Copy Parsing** - Minimized allocations and string operations
- **Lock-Free Optimizations** - Poison-resistant locking with graceful failure recovery
- **Hot Value Cache** - 457ns average access time for frequently used values
- **Cache Hit Ratio Tracking** - Built-in performance statistics and monitoring
### ๐ง **Production Features**
- **Configuration Hot Reloading** - File watching with thread-safe Arc swapping
- **Audit Logging System** - Structured event logging with multiple sinks and severity filtering
- **Environment Variable Overrides** - Smart caching with prefix matching and type conversion
- **Schema Validation** - Trait-based validation system with feature gates
- **Format Preservation** - Maintains comments, whitespace, and original formatting
- **Async Native** - Full async/await support throughout the API
### ๐ก๏ธ **Reliability & Safety**
- **Zero Unsafe Code** - All `unwrap()` calls eliminated, comprehensive error handling
- **Type Safety** - Rich type system with automatic conversions and validation
- **Enterprise Error Handling** - Production-ready error messages with context preservation
- **Comprehensive Testing** - 89+ unit tests, integration tests, and doc tests
---
## ๐ Quick Start
```rust
use config_lib::Config;
// Parse any supported format automatically
let mut config = Config::from_string(r#"
[database]
host = "localhost"
port = 5432
username = "admin"
[app]
name = "MyApp"
debug = true
"#, None)?;
// Access values with type safety
let host = config.get("database.host")?.as_string()?;
let port = config.get("database.port")?.as_integer()?;
let debug = config.get("app.debug")?.as_bool()?;
// Modify configuration (preserves format and comments)
config.set("database.port", 5433)?;
config.set("app.version", "1.0.0")?;
println!("Connecting to {}:{}", host, port);
```
### โจ **New in v0.6.0: Bulletproof API**
```rust
use config_lib::{ConfigBuilder, ConfigValue};
// All 8 formats now fully operational (TOML/NOML re-enabled)
let config = ConfigBuilder::new()
.format("toml") // TOML now works reliably!
.from_string(r#"
[server]
port = 8080
host = "localhost"
"#)?;
// Consistent API patterns across all parsers
let port = config.key("server.port").as_integer()?;
let timeout = config.key("timeout").as_integer().unwrap_or(30);
let name = config.key("app.name").as_string_or("DefaultApp");
// Check existence
if config.has("server.ssl") {
println!("SSL configuration found");
}
```
### ๐ฅ **Enterprise Caching**
```rust
use config_lib::EnterpriseConfig;
// High-performance cached configuration
let mut config = EnterpriseConfig::new();
config.load_from_file("app.conf")?;
// Sub-50ns cached access (24.9ns average)
let cached_value = config.get_cached("database.host")?;
// View cache performance stats
let stats = config.cache_stats()?;
println!("Cache hit ratio: {:.2}%", stats.hit_ratio * 100.0);
```
### ๐ **Hot Reloading & Audit Logging**
```rust
use config_lib::{Config, audit};
// Enable audit logging
let audit_logger = audit::AuditLogger::new()
.with_console_sink(audit::Severity::Info)
.with_file_sink("config_audit.log", audit::Severity::Warning)?;
// Hot reloading configuration
audit_logger.log_reload("app.conf", "admin");
})?;
```
---
## ๐ฆ Installation
Add to your `Cargo.toml`:
```toml
[dependencies]
config-lib = "0.6.0"
# Optional enterprise features
config-lib = { version = "0.6.0", features = [
"json", # JSON format support
"xml", # XML format support
"hcl", # HCL format support
"toml", # TOML format support (now bulletproof!)
"noml", # NOML format support (now bulletproof!)
"validation", # Schema validation
"async", # Async operations
"env-override", # Environment variable overrides
] }
```
---
## ๐ฏ **Current Status: v0.6.0**
**Stability**: โ
**Bulletproof** - API finalized with comprehensive parser consistency
**What's Working**:
- โ
All 8 configuration formats (CONF, INI, JSON, XML, HCL, Properties, NOML, TOML)
- โ
**Bulletproof Parser Availability** - TOML/NOML fully operational after critical fixes
- โ
**Consistent API Patterns** - All parsers use standardized `module::parse()` calling convention
- โ
**Feature Flag Alignment** - Cargo.toml features match actual parser availability
- โ
Enterprise caching system (24.9ns average access time)
- โ
Hot reloading and audit logging
- โ
Environment variable overrides and validation
- โ
Comprehensive test suite (89+ tests, 100% passing, zero clippy warnings)
- โ
Enhanced API with ConfigBuilder and ConfigValue
- โ
Zero unsafe code, production-ready error handling
**Performance Achievements**:
- ๐ **24.9ns** cached value access (50% better than 50ns target)
- ๐ **457ns** average hot cache access time
- ๐ **Zero-copy** parsing where possible
- ๐ **Lock-free** optimizations throughout
**v0.6.0 Bulletproof Upgrades**:
- ๐ง **Parser Availability Crisis Resolved** - Re-enabled TOML/NOML in main parsing logic
- ๐ง **API Consistency Standardized** - All 8 parsers follow uniform `module::parse()` patterns
- ๐ง **Feature Flag Alignment** - Cargo.toml features now match actual parser availability
- ๐ง **Zero Clippy Warnings** - Completely clean codebase with optimized recursive validation
- ๐ง **Comprehensive Testing** - 89+ tests covering all formats and edge cases
---
## ๐ **Roadmap**
| **0.4.x** | โ
Core functionality & enterprise features | Released |
| **0.5.x** | ๏ฟฝ API expansion & additional functionality | Released |
| **0.6.x** | ๐ก๏ธ API finalization & bulletproofing | **Current** |
| **0.7.x** | ๐จ Code cleanup, optimization & polish | **Next** |
| **0.8.x** | โก Peak performance optimization & security | **Planned** |
| **0.9.x** | ๐งช Beta/RC with community testing | **Planned** |
| **1.0.x** | ๐ Stable release | **Goal** |
---
## ๐ **Documentation**
- **[API Documentation](https://docs.rs/config-lib)** - Complete API reference
- **[Examples](examples/)** - 19 comprehensive examples covering all features
- **[Benchmarks](benches/)** - Performance benchmarks and comparisons
---
## ๐ค **Contributing**
We welcome contributions! See our [Contributing Guide](CONTRIBUTING.md) for details.
---
## ๐ **License**
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.