Zero-boilerplate configuration management.
Focus on storing the right data, instead of worrying about how or where to store it.
```rust use serde_derive::{Serialize, Deserialize};
struct MyConfig { version: u8, api_key: String, }
fn main() -> Result<(), ::std::io::Error> { let cfg: MyConfig = confy::load("my-app-name", None)?; dbg!(cfg); Ok(()) } ```
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.
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
:
toml
[dependencies.confy]
features = ["yaml_conf"]
default-features = false
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
:
toml
[dependencies.confy]
features = ["ron_conf"]
default-features = false
load
and store
have been added an optional parameter in the event multiples configurations are needed, or ones with different filename.load
and store
to be the same of the first one to keep the previous configuration file.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.