Confique is a rather light-weight library that helps with configuration management in a type-safe and DRY (don't repeat yourself) fashion.
Features:
unwrap
any Option
s.
All values already have the correct type.serde
Deserializer (built-in support for more formats coming soon)serde
: less code in confique
(more light-weight) and access to a huge ecosystem of high quality parsers.```rust use std::path::PathBuf; use confique::Config;
struct Conf { #[config(env = "EXAMPLEAPPUSERNAME")] username: String,
#[config(env = "EXAMPLE_APP_BUFFER_SIZE", default = 4096)]
buffer_size: u32,
#[config(nested)]
log: LogConf,
}
struct LogConf { #[config(default = true)] stdout: bool,
file: Option<PathBuf>,
}
let config = Conf::builder() .env() .file("example-app.toml") .file("/etc/example-app/config.toml") .load()?; ```
See the documentation for more information.
Obviously, all other libraries are more mature than confique.
config
"http.port"
) and deserialize at "use site".figment
serde
and also uses your own structs as data store, thus type safeserde
?Serde is not a configuration, but a deserialization library.
But you can get surprisingly far with just serde and it might actually be sufficient for your project.
However, once you want to load from multiple sources, you either have make all your fields Option
or repeat code/docs.
With confique
you also get some other handy helpers.
Confique is still a very young project. There are lots of features and improvements already planned. I'm developing this library alongside a web project that uses it.
Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.