#config #xml #export #traits #default #struct #yaml #deserialize

cdumay_config

A Rust Library for configuration manipulation and export

1 unstable release

Uses new Rust 2024

new 0.1.1 May 15, 2025

#2884 in Parser implementations

Custom license

39KB
390 lines

cdumay_config

License: BSD-3-Clause cdumay_config on crates.io cdumay_config on docs.rs Source Code Repository

A flexible configuration management library that provides a trait-based approach for handling key-value data with support of multiple serialization formats.

Features

  • Generic configuration management through the Manager trait
  • Support for multiple serialization formats (with feature flags):
    • JSON (default)
    • TOML (feature: "toml")
    • YAML (feature: "yaml")
    • XML (feature: "xml")
  • Type-safe error handling with the cdumay_error::Error struct

Example Usage

#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct DatabaseConfig {
    pub user: String,
    pub password: String,
    pub database: String,
}

fn main() -> cdumay_error::Result<()> {
    let context = std::collections::BTreeMap::new();
    let config = DatabaseConfig {
        user: "john".to_string(),
        password: "smith".to_string(),
        database: "example".to_string()
    };
    let _ = cdumay_config::write_config(
        "locker-db.json",
        Some(cdumay_config::ContentFormat::JSON),
        config,
        &context
    )?;
    Ok(())
}

Dependencies

~1–2.4MB
~49K SLoC