-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INI format support #72
Comments
I'd be happy to add support for INI. Last I checked, there was no obvious candidate for a serde support crate we could use. Has this changed? If so, I'd be happy to accept a PR. The implementation is almost trivial as it's a simple implementation of the |
config-rs uses https://docs.rs/rust-ini/latest/ini/, but serde support is an open issue zonyitoo/rust-ini#40 I haven't looked at https://github.com/arcnmx/serde-ini |
Figment is built around serde, so the crate must support serde, and support it rather well. Otherwise, please note that you can trivially implement support for INI entirely outside of Figment by implementing the struct Ini;
impl Format for Ini {
type Error = serde_ini::de::Error;
const NAME: &'static str = "INI";
fn from_str<'de, T: DeserializeOwned>(string: &'de str) -> Result<T, Self::Error> {
serde_ini::de::from_str(string)
}
} Then you can use it just like use figment::providers::Format;
Figment::new()
.merge(Ini::file("myapp.conf"))
.join(Ini::file("defaults.conf")) |
I use INI.
(If you're wondering why, I prefer to spare my (often non-technical) users from having to worry about significant whitespace (YAML), syntax errors and escape characters (JSON, TOML, XML, YAML), nesting errors (XML, YAML) – and I want to provide in-line documentation via comments (not in JSON).)
The text was updated successfully, but these errors were encountered: