| Crates.io | yaml-patch |
| lib.rs | yaml-patch |
| version | 0.1.1 |
| created_at | 2021-02-14 16:30:55.305138+00 |
| updated_at | 2021-02-14 16:32:56.127591+00 |
| description | Merge YAML values together to enable hierarchical configurations |
| homepage | |
| repository | https://github.com/clemson-cal/yaml-patch |
| max_upload_size | |
| id | 355123 |
| size | 7,337 |
Merge serde_yaml::Value's together to enable hierarchical configurations
This crate extends any type which implements serde::Serialize and serde::Deserialize with four additional methods:
patch_from_valuepatch_from_strpatch_from_readerpatch_from_key_valFor example, given a type
#[derive(Serialize, Deserialize)]
struct Configuration {
a: f64,
b: String,
}
you can update the data members of an instance from a serde_yaml::Value::Mapping with optional keys "a" or "b". You can also patch an instance from a file (or anything std::io::Read) with valid YAML content:
let file = File::open("config.yaml")?;
config.patch_from_reader(file)?;
The crate also supports a key-path style YAML sytax syntax extension: for example event.patch_from_key_val("date.year=2021").
Add the following to your Cargo.toml:
[dependencies]
yaml-patch = "*"