config-lib 0.6.0

A configuration parsing library supporting CONF, NOML, TOML, and JSON formats.
Documentation
<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
let config = Config::from_file_with_hot_reload("app.conf", move |new_config| {
    println!("Configuration reloaded!");
    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**

| Version | Focus | Status |
|---------|-------|--------|
| **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.