Crate cdumay_config

Crate cdumay_config 

Source
Expand description

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_core::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_core::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(())
}

Structs§

ConfigurationFileError
Error : ConfigurationFileError (Kind: InvalidConfiguration)
JsonManager
JSON configuration file manager implementing the Manager trait.
TomlManager
TOML configuration file manager implementing the Manager trait.
VaultConfig
Configuration structure for loading secrets from an external file.
VaultSecret
Represents a single secret stored in the vault.
VaultSecretError
Error : VaultSecretError (Kind: InvalidConfiguration)
VaultSecrets
A collection of multiple secrets loaded from a configuration source.
XmlManager
XML configuration file manager implementing the Manager trait.
YamlManager
YAML configuration file manager implementing the Manager trait.

Enums§

ContentFormat
Enum representing the supported content formats for configuration files.

Traits§

Manager
A trait defining common operations for configuration file managers.

Functions§

read_config
Reads a configuration file and deserializes its content into a strongly typed Rust value.
write_config
Serializes and writes a Rust value to a configuration file in a specified format.