From cb4888dbbd3f2ebd1bd4e35fb07fb2fe0facafe8 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Sun, 30 Jul 2017 14:22:50 -0700 Subject: Impl Deserializer for Config (to forward Value) --- src/config.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index f890461..fac76a5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::ops::Deref; use std::str::FromStr; use std::fmt::Debug; -use serde::de::Deserialize; +use serde::de::{Deserialize, Deserializer}; use error::*; use source::Source; @@ -110,11 +110,6 @@ impl Config { Ok(self) } - /// Deserialize the entire configuration. - pub fn deserialize<'de, T: Deserialize<'de>>(&self) -> Result { - T::deserialize(self.cache.clone()) - } - pub fn set_default(&mut self, key: &str, value: T) -> Result<&mut Config> where T: Into, @@ -189,6 +184,11 @@ impl Config { pub fn get_array(&self, key: &str) -> Result> { self.get(key).and_then(Value::into_array) } + + /// Attempt to deserialize the entire configuration into the requested type. + pub fn try_into<'de, T: Deserialize<'de>>(self) -> Result { + T::deserialize(self) + } } impl Source for Config { -- cgit v1.2.3