use figment::providers::Format;
use serde::de::DeserializeOwned;
use serde_saphyr::{DuplicateKeyPolicy, MergeKeyPolicy};
pub struct Yaml;
impl Format for Yaml {
type Error = serde_saphyr::Error;
const NAME: &'static str = "YAML";
fn from_str<T: DeserializeOwned>(string: &str) -> Result<T, Self::Error> {
serde_saphyr::from_str_with_options(
string,
serde_saphyr::options! {
strict_booleans: true,
merge_keys: MergeKeyPolicy::AsOrdinary,
duplicate_keys: DuplicateKeyPolicy::LastWins,
with_snippet: false,
},
)
}
}