from_yaml

Function from_yaml 

Source
pub fn from_yaml(partial: &mut Partial<'_>, yaml: &str) -> Result<(), String>
Expand description

Deserializes YAML data into a Shapely Partial.

ยงExample

use shapely::Shapely;
use shapely_yaml::from_yaml;

#[derive(Debug, Shapely, PartialEq)]
struct Config {
    name: String,
    version: u64,
}

let yaml = r#"
name: MyApp
version: 1
"#;

let mut partial = Config::partial();
from_yaml(&mut partial, yaml).expect("Failed to parse YAML");

let config = partial.build::<Config>();
assert_eq!(config, Config { name: "MyApp".to_string(), version: 1 });