<#@ template cleanws="true" #> impl Connection { /// Get a property by its id. pub fn get_property(&self, id: &PropertyId) -> Result { Ok(match id { <# for struc in &self.0.structs { let mut ids = embrace(&get_ids(struc)); let mut ids2 = get_ids2(&self.0.structs, struc); ids2 = format!("({})", ids2); #> PropertyId::<#= struc.name #><#= ids #> => PropertyValueRef::<#= struc.name #>(self.get_<#= struc.name.to_snake_case() #><#= ids2 #>?), <# } #> <# for struc in self.0.structs.iter().filter(|s| !s.opt) { for p in struc.get_properties(&self.0.structs) { let type_s = p.get_inner_type_as_name()?; let mut ids = get_ids(struc); if p.modifier.is_some() { if !ids.is_empty() { ids.push_str(", "); } ids.push_str("m"); } ids = embrace(&ids); let mut ids2 = format!("({})", get_ids2(&self.0.structs, struc)); #> PropertyId::<#= struc.name #><#= p.get_name() #><#= ids #> => PropertyValueRef::<#= type_s #>(self.get_<#= struc.name.to_snake_case() #><#= ids2 #>?.<#= p.name.to_snake_case() #><# if p.modifier.as_ref().map(|s| s == "map").unwrap_or(false) { #>.get(*m) .ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<# } else if p.modifier.as_ref().map(|s| s == "array").unwrap_or(false) { #>.iter()<# if p.type_s != "str" { #>.cloned().find(|i| i == m)<# } else { #>.find(|i| *i == m)<# } #> .ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<# } else if p.modifier.as_ref().map(|s| s == "set").unwrap_or(false) { #>.get(m)<# if p.type_s != "str" { #>.cloned()<# } #> .ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<# } if p.opt && (p.type_s == "str" || p.type_s == "Uid") { #>.as_ref().map(|r| r.as_ref())<# } else if p.type_s == "str" || p.type_s == "Uid" || ["TalkPowerRequest", "EccKeyPubP256"].contains(&p.type_s.as_str()) { #>.as_ref()<# } #>), <# } } #> }) } }