From 16f04b9d79e45e718c9c04665eb32a9b7c9a6ed8 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 14 Jan 2020 14:19:22 +0100 Subject: [PATCH] src/section_config.rs: add lookup_json() helper --- src/section_config.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/section_config.rs b/src/section_config.rs index 0bee518e..12564580 100644 --- a/src/section_config.rs +++ b/src/section_config.rs @@ -61,22 +61,23 @@ impl SectionConfigData { Ok(()) } - pub fn lookup(&self, type_name: &str, id: &str) -> Result { - - let config = match self.sections.get(id) { + pub fn lookup_json(&self, type_name: &str, id: &str) -> Result { + match self.sections.get(id) { Some((section_type_name, config)) => { if type_name != section_type_name { bail!("got unexpected type '{}' for {} '{}'", section_type_name, type_name, id); } - config + Ok(config.clone()) } None => { bail!("no such {} '{}'", type_name, id); } - }; - - let data = T::deserialize(config.clone())?; + } + } + pub fn lookup(&self, type_name: &str, id: &str) -> Result { + let config = self.lookup_json(type_name, id)?; + let data = T::deserialize(config)?; Ok(data) }