All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
Please note that we had to update the MSRV for this crate from 1.56.0 to 1.59.0 for this patch release being possible, because a transitive dependency did update its MSRV.
Clone
trait derive to builder statesFormat
trait for (custom) file formats #219Environment::new()
- see #235Config
interface - see #196Config::merge()
Config::with_merged()
Config::refresh()
Config::set_default()
Config::set()
Config::set_once()
Config::deserialize()
Config
type got a builder-pattern with_merged()
method #166.Config::set_once()
function was added, to set an value that can be overwritten by Config::merge
ing another configuration #172#[serde(default)]
#106enum
s from configuration. #85// Empty env variables will not be collected Environment::with_prefix("APP").ignore_empty(true)
Breaking Change: Environment does not declare a separator by default.
// 0.8.0 Environment::with_prefix("APP") // 0.9.0 Environment::with_prefix("APP").separator("_")
Add support for INI. #72
Add support for newtype structs. #71
Fix bug with array set by path. #69
Update to nom 4. #63
derive(PartialEq)
for Value (#54)[https://github.com/mehcode/config-rs/pull/54]serde_yaml
. #39Implement Source
for Config
.
Implement serde::de::Deserializer
for Config
. my_config.deserialize
may now be called as either Deserialize::deserialize(my_config)
or my_config.try_into()
.
Remove ConfigResult
. The builder pattern requires either .try_into
as the final step or the initial Config::new()
to be bound to a slot. Errors must also be handled on each call instead of at the end of the chain.
let mut c = Config::new(); c .merge(File::with_name("Settings")).unwrap() .merge(Environment::with_prefix("APP")).unwrap();
let c = Config::new() .merge(File::with_name("Settings")).unwrap() .merge(Environment::with_prefix("APP")).unwrap() // LLVM should be smart enough to remove the actual clone operation // as you are cloning a temporary that is dropped at the same time .clone();
let mut s: Settings = Config::new() .merge(File::with_name("Settings")).unwrap() .merge(Environment::with_prefix("APP")).unwrap() .try_into();
Implement Source
for Vec<T: Source>
and Vec<Box<Source>>
Config::new() .merge(vec![ File::with_name("config/default"), File::with_name(&format!("config/{}", run_mode)), ])
Implement From<&Path>
and From<PathBuf>
for File
Remove namespace
option for File
Add builder pattern to condense configuration
Config::new() .merge(File::with_name("Settings")) .merge(Environment::with_prefix("APP")) .unwrap()
Parsing errors even for non required files – @Anthony25 ( #33 )
config.get
has been changed to take a type parameter and to deserialize into that type using serde. Old behavior (get a value variant) can be used by passing config::Value
as the type parameter: my_config.get::<config::Value>("..")
. Some great help here from @impowski in #25.File
. This is likely temporary. I do want this behavior but I can see how it should be optional. See #35File::with_name
to get automatic file format detection instead of manual FileFormat::*
– @JordiPolomy_config.refresh()
will do a full re-read from the source so live configuration is possible with some work to watch the fileRemove global ( config::get
) API — It's now required to create a local configuration instance with config::Config::new()
first.
If you'd like to have a global configuration instance, use lazy_static!
as follows:
use std::sync::RwLock; use config::Config; lazy_static! { static ref CONFIG: RwLock<Config> = Default::default(); }
config::File::from_str
to parse and merge a file from a stringconfig::get_table
and config::get_array
Initial release.