confetti-rs 0.1.0

A configuration language and parser library written in Rust
Documentation
  • Coverage
  • 86.32%
    82 out of 95 items documented2 out of 34 items with examples
  • Size
  • Source code size: 140.54 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.21 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • shkmv/confetti-rs
    7 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • shkmv

Confetti-rs

Rust crates.io Documentation License: MIT

A configuration language and parser library for Rust, with a flexible mapper for converting between configuration files and Rust structs.

Features

  • Simple, intuitive configuration syntax
  • A powerful parser with customizable options
  • Automatic mapping between configuration and Rust structs
  • Support for custom data types
  • Comprehensive error handling

Installation

Add this to your Cargo.toml:

[dependencies]
confetti-rs = "0.1.0"

# If you need derive macros
confetti-rs = { version = "0.1.0", features = ["derive"] }

Basic Usage

use confetti_rs::{ConfMap, from_str, to_string};
use std::error::Error;

// Define a configuration structure
#[derive(ConfMap, Debug)]
struct ServerConfig {
    host: String,
    port: i32,
    #[conf_map(name = "ssl-enabled")]
    ssl_enabled: bool,
    max_connections: Option<i32>, 
}

fn main() -> Result<(), Box<dyn Error>> {
    // Configuration string in Confetti syntax
    let config_str = r#"
    ServerConfig {
        host "localhost";
        port 8080;
        ssl-enabled false;
        max_connections 100;
    }
    "#;

    // Parse the configuration
    let server_config = from_str::<ServerConfig>(config_str)?;
    println!("Loaded config: {:?}", server_config);

    // Serialize to a string
    let serialized = to_string(&server_config)?;
    
    Ok(())
}

More Information

For more examples and detailed documentation, please visit: