lib

mogh_config (0.1.0)

Published 2026-01-04 21:13:04 +00:00 by max

Installation

[registry]
default = "forgejo"

[registries.forgejo]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add mogh_config@0.1.0

About this package

Mogh Config

Module for comprehensive loading of strongly typed configuration files using std::fs and serde.

  • Supports parsing JSON, YAML, and TOML formatted files.
  • Supports merging final configuration from multiple supplied files / directories.
#[derive(serde::Deserialize)]
struct Config {
  title: String,
  aliases: Vec<String>,
  endpoint: String,
  use_option: bool,
}

let config = (ConfigLoader {
  // Read config files from a directory
  paths: vec![PathBuf::from("./configs")],
  match_wildcards: vec![String::from("*config*.toml")],
  // It won't recurse into subdirectories unless they include '.configinclude' file
  include_file_name: ".configinclude",
  merge_nested: true,
  extend_array: true,
  debug_print: true,
})
.load::<Config>()
.expect("Failed to parse config from path");

Dependencies

ID Version
colored ^3.0.0
indexmap ^2.12.1
regex ^1.12.2
serde ^1.0.228
serde_json ^1.0.148
serde_yaml_ng ^0.10.0
thiserror ^2.0.17
toml ^0.9.8
wildcard ^0.3.0
Details
Cargo
2026-01-04 21:13:04 +00:00
2
moghtech <contact@mogh.tech>
MIT
8.7 KiB
Assets (1)
Versions (1) View all
0.1.0 2026-01-04