Rewrite to use derive macro

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-05-11 13:37:14 +02:00
parent d5eb918523
commit 5f5ce54edb
2 changed files with 4 additions and 9 deletions

View file

@ -37,17 +37,17 @@
while_true, while_true,
)] )]
#[macro_use] extern crate log; extern crate log;
extern crate itertools; extern crate itertools;
extern crate ansi_term; extern crate ansi_term;
extern crate handlebars; extern crate handlebars;
extern crate serde; extern crate serde;
#[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_derive;
#[macro_use] extern crate failure; #[macro_use] extern crate failure;
#[macro_use] extern crate toml_query;
extern crate clap; extern crate clap;
extern crate toml; extern crate toml;
extern crate toml_query;
extern crate atty; extern crate atty;
extern crate libimagstore; extern crate libimagstore;

View file

@ -349,7 +349,6 @@ mod log_lvl_aggregate {
fn aggregate_module_settings(_matches: &ArgMatches, config: Option<&Value>) fn aggregate_module_settings(_matches: &ArgMatches, config: Option<&Value>)
-> Result<BTreeMap<ModuleName, ModuleSettings>> -> Result<BTreeMap<ModuleName, ModuleSettings>>
{ {
use toml_query::read::Partial;
use std::convert::TryInto; use std::convert::TryInto;
// //
@ -369,14 +368,10 @@ fn aggregate_module_settings(_matches: &ArgMatches, config: Option<&Value>)
pub enabled: bool, pub enabled: bool,
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Partial, Serialize, Deserialize, Debug)]
#[location = "imag.logging.modules"]
struct LoggingModuleConfigMap(BTreeMap<String, LoggingModuleConfig>); struct LoggingModuleConfigMap(BTreeMap<String, LoggingModuleConfig>);
impl<'a> Partial<'a> for LoggingModuleConfigMap {
const LOCATION: &'static str = "imag.logging.modules";
type Output = Self;
}
impl TryInto<BTreeMap<String, ModuleSettings>> for LoggingModuleConfigMap { impl TryInto<BTreeMap<String, ModuleSettings>> for LoggingModuleConfigMap {
type Error = Error; type Error = Error;