Crates.io | config-dirs |
lib.rs | config-dirs |
version | 0.2.0 |
source | src |
created_at | 2024-06-16 21:11:29.421692 |
updated_at | 2024-10-27 00:09:00.421004 |
description | Load a config file by trying out default config file locations |
homepage | |
repository | https://github.com/nitn3lav/config-dirs-rs |
max_upload_size | |
id | 1273861 |
size | 16,914 |
Load a config file by trying out default config file locations:
{NAME_SCREAMING_SNAKE_CASE}_CONFIG
envitonment variable~/.config/{name}/config.toml
/etc/{name}/config.toml
/usr/local/etc/{name}/config.toml
~/Library/Preferences/{name}/config.toml
/usr/local/etc/{name}/config.toml
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
struct Config {}
let config: Config = config_dirs::load("my-app", toml::from_str).expect("Failed to load config");
The case conversion of name
for the environment variable is done using convert_case::Case::ScreamingSnake
.