use crate::spec::production_spec::{ ProductionBooleanFrom, ProductionBuildSpec, ProductionKind, ProductionStringFrom, }; use yaml_rust2::Yaml; pub fn deserialize_production(name: &str, props: &Yaml) -> ProductionBuildSpec { let kind = match props["kind"].as_str().unwrap() { "int" => ProductionKind::Int, "long" => ProductionKind::Long, "double" => ProductionKind::Double, "string" => { let from = match props["from"].as_str().unwrap() { "string_inner" => ProductionStringFrom::StringInner, "whole_pair" => ProductionStringFrom::WholePair, _ => panic!( "Unknown string production from: {}", props["from"].as_str().unwrap() ), }; ProductionKind::String(from) } "boolean" => ProductionKind::Boolean(ProductionBooleanFrom::ParseWholePair), _ => panic!( "Unknown production kind: {}", props["kind"].as_str().unwrap() ), }; ProductionBuildSpec::new(name, kind) }