#configuration #platform #store #having #directories #locally #config-directory

configstore

Library to store configurations of applications locally without having to worry about directories or platforms

4 releases

0.1.3 May 25, 2020
0.1.2 May 25, 2020
0.1.1 May 18, 2020
0.1.0 May 18, 2020

#583 in Configuration

Download history 15/week @ 2024-03-31 1/week @ 2024-04-07 4/week @ 2024-05-12 1/week @ 2024-05-19 22/week @ 2024-06-02 3/week @ 2024-06-09 23/week @ 2024-06-16 7/week @ 2024-06-23 1/week @ 2024-06-30 23/week @ 2024-07-07

54 downloads per month
Used in 3 crates (via update-notifier)

MPL-2.0 license

11KB
116 lines

Configstore crates.io status

Configstore is a library that allows you to store your configurations locally without having to worry about the directories or the platform

Usage

To use configstore, add this to your Cargo.toml:

[dependencies]
configstore = "0.1"

Initialize your Configstore

use configstore::{Configstore, AppUI};
fn main() {
    let config_store = Configstore::new("myApp", AppUI::CommandLine).unwrap();
}

Set and get values

Configstore supports any value that implements Deserialize and Serialize

use serde_derive::*;
use configstore::{Configstore, AppUI};

#[derive(Deserialize, Serialize, Eq, PartialEq, Debug, Clone)]
struct Value {
    text: String,
    num: u32
}

let config_store = Configstore::new("myApp", AppUI::CommandLine).unwrap();

let value = Value {text: "hello world".to_string(), num: 4343};
config_store.set("key", value.clone()).unwrap();

let same_value: Value = config_store.get("key").unwrap();
assert_eq!(value, same_value);

Configstore will store the configuration files under your platforms native config directory based on platform-dirs

Contributing

All contributions are welcome, feel free to file an issue or even a pull-request 🤝

License

This project is licensed under the Mozilla Public License 2.0

Dependencies

~0.8–2MB
~38K SLoC