High-performance Rust implementation of the CFG++ parser with zero-copy parsing and advanced optimizations.
- 🚀 Blazing Fast: Zero-copy parsing with SIMD optimizations
- 🛡️ Memory Safe: Rust's ownership system prevents memory errors
- 🔧 Schema Validation: Built-in schema validation with detailed errors
- 📦 Serde Integration: Seamless JSON/TOML/YAML conversion
- 🧵 Thread Safe: Concurrent parsing and processing
- 📊 Benchmarked: Comprehensive performance test suite
Basic Config (1KB): ~50μs
Large Config (100KB): ~2ms
Nested Objects: ~100μs
Schema Validation: ~200μs
# Add to Cargo.toml
[dependencies]
cfgpp = "0.1.0"
# Or install CLI
cargo install cfgpp-cliuse cfgpp::{Parser, CfgppValue};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = r#"
database {
host = "localhost";
port = 5432;
ssl = true;
}
"#;
let mut parser = Parser::new();
let value: CfgppValue = parser.parse(config)?;
// Access values with type safety
if let Some(host) = value.get_path("database.host").as_string() {
println!("Database host: {}", host);
}
Ok(())
}use cfgpp::{Parser, ParserOptions, Schema};
// Custom parser options
let options = ParserOptions {
expand_env_vars: true,
process_includes: true,
max_include_depth: 5,
..Default::default()
};
let mut parser = Parser::with_options(options);
// Schema validation
let schema = Schema::parse_file("config.schema")?;
let config = parser.parse_file("config.cfgpp")?;
schema.validate(&config)?;
// Convert to JSON
let json = config.to_json()?;# Run performance benchmarks
cargo bench
# View benchmark results
open target/criterion/report/index.htmlAvailable features:
std(default): Standard library supportserde: JSON/TOML/YAML serializationschema-validation: Schema validation supportparallel: Parallel processing with rayonmmap: Memory-mapped file I/Osimd: SIMD optimizations
# Enable all features
cargo build --all-features
# Minimal build
cargo build --no-default-features --features stdSee the Rust API documentation for complete details.