7 releases (4 breaking)

0.5.1 Oct 25, 2022
0.5.0 Sep 8, 2022
0.4.0 Mar 13, 2020
0.3.1 Dec 6, 2018
0.1.0 Mar 8, 2016

#7 in Configuration

Download history 10341/week @ 2023-08-15 10706/week @ 2023-08-22 9870/week @ 2023-08-29 10580/week @ 2023-09-05 10325/week @ 2023-09-12 10642/week @ 2023-09-19 9441/week @ 2023-09-26 10505/week @ 2023-10-03 11327/week @ 2023-10-10 10318/week @ 2023-10-17 12776/week @ 2023-10-24 11969/week @ 2023-10-31 10034/week @ 2023-11-07 9824/week @ 2023-11-14 7974/week @ 2023-11-21 9143/week @ 2023-11-28

38,632 downloads per month
Used in 162 crates (158 directly)

MIT/X11 OR Apache-2.0

277 lines


crates.io docs.rs Discord

Zero-boilerplate configuration management.

Focus on storing the right data, instead of worrying about how or where to store it.

use serde_derive::{Serialize, Deserialize};

#[derive(Default, Debug, Serialize, Deserialize)]
struct MyConfig {
    version: u8,
    api_key: String,

fn main() -> Result<(), ::std::io::Error> {
    let cfg: MyConfig = confy::load("my-app-name", None)?;

Confy's feature flags

Confy can be used with either TOML, YAML, or RON files. TOML is the default language used with confy but any of the other languages can be used by enabling them with feature flags as shown below.

Note: you can only use one of these features at a time, so in order to use either of the optional features you have to disable default features.

Using yaml

To use YAML files with confy you have to make sure you have enabled the yaml_conf feature and disabled both toml_conf and ron_conf.

Enable the feature in Cargo.toml:

features = ["yaml_conf"]
default-features = false

Using ron

For using RON files with confy you have to make sure you have enabled the ron_conf feature and disabled both toml_conf and yaml_conf.

Enable the feature in Cargo.toml:

features = ["ron_conf"]
default-features = false

Breaking changes

Version 0.5.0

  • The base functions load and store have been added an optional parameter in the event multiples configurations are needed, or ones with different filename.
  • The default configuration file is now named "default-config" instead of using the application's name. Put the second argument of load and store to be the same of the first one to keep the previous configuration file.
  • It is now possible to save the configuration as toml or as yaml. The configuration's file name's extension depends on the format used.

Version 0.4.0

Starting with version 0.4.0 the configuration file are stored in the expected place for your system. See the directories crates for more information. Before version 0.4.0, the configuration file was written in the current directory.


~33K SLoC